MainWindow漫谈

漫谈.1

加速键和快捷键不一样

加速键:alt + ...

快捷键:ctrl + ...

加速键用来启用文件菜单,快捷键用来启用菜单里面的动作!

 

漫谈.2

toolButtonStyle设置图标和应用文本的显示及其相对位置
movabel设置状态栏是否可以移动
allowedArea设置允许停靠的位置
iconsize设置图标的大小
floatable设置是否可以悬浮

两点说明:

  • 往工具栏添加部件可以使用addWidget()函数
  • 其实往工具栏添加一个QAction类对象就会自动创建一个QToolButton,所以,工具栏上的动作就是一个QToolButton,这就解释了为什么属性栏有toolButtonStyle属性的原因。

演示 QToolButton和addWidget

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // create a tooButton
    QToolButton *toolBtColor = new QToolButton(this);
    toolBtColor->setText("color");

    // crete a menu and add two action to menu
    QMenu *menu = new QMenu(this);
    menu->addAction("red");
    menu->addAction("blue");

    // add menu to tooButton
    toolBtColor->setMenu(menu);
    toolBtColor->setPopupMode(QToolButton::MenuButtonPopup);

    ui->mainToolBar->addWidget(toolBtColor);

    // add an widget to tooBar
    QSpinBox *spinBox = new QSpinBox(this);
    ui->mainToolBar->addWidget(spinBox);
}

 

参考:

不二如是:https://fishc.com.cn/forum.php?mod=viewthread&tid=76886&extra=page%3D5%26filter%3Dauthor%26orderby%3Ddateline%26typeid%3D449

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sssnial-jz

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值