Can you add a toolbar to QDialog?

后端 未结 3 841
自闭症患者
自闭症患者 2020-12-17 18:29

I\'m working on a project that needs to call a modal window with a toolbar to do some work on some data before it\'s loaded. The reason I need the toolbar is the user has a

3条回答
  •  余生分开走
    2020-12-17 19:00

    You can add QToolBar in QDialog. But as a QWidget. Please have a look

    MyDialog::MyDialog(QWidget *parent) : QDialog(parent)
    {
       QVBoxLayout *mainLayout = new QVBoxLayout(this);
    
       QToolBar *toolBar = new QToolBar();
       mainLayout->addWidget(toolBar);
    
       QAction *action1 = new QAction("Add", toolBar);
       QAction *action1 = new QAction("Del", toolBar);
    
      //Add What you want
    }
    

    As QToolBar is child of QWidget we can add it as Widget. Using Layout you can adjust its position. Please check this link http://developer.nokia.com/community/wiki/How_to_use_QToolBar_and_QToolButton_in_Qt

提交回复
热议问题