[solved] qtoolbar: one under the other



  • I have two toolbar.
    I'd like to put one under the other (or one next the other...) programatically.
    How can I solve this?



  • I did something like this:

    @
    QWidget* widget = new QWidget();
    QVBoxLayout* widgetLayout = new QVBoxLayout();

    QToolBar* widgetToolbar1 = new QToolBar(widget);

    QAction* newAction = new QAction(QIcon(":/File/new-icon64.png"), tr("New"), widgetToolbar1);
    newAction->setToolTip(tr("Create a New Page"));
    widgetToolbar1->addAction(newAction);
    connect(newAction, SIGNAL(triggered()), this, SLOT(onClickNew()));

    //add more actions

    QToolBar* widgetToolbar2 = new QToolBar(widget);

    QAction* boldAction = new QAction(QIcon(":/Text_Format/bold-icon64.png"), "Bold", widgetToolbar2);
    boldAction->setToolTip(tr("Toggle the Current Selection 'bold' Property"));
    widgetToolbar2->addAction(boldAction);
    connect(boldAction, SIGNAL(triggered()), this, SLOT(onClickBold()));

    //add more actions

    widgetLayout->setContentsMargins(0, 0, 0, 0);
    widgetLayout->setSpacing(0);
    widgetLayout->addWidget(widgetToolbar1);
    widgetLayout->addWidget(widgetToolbar2);
    widget->setLayout(widgetLayout);
    @



  • Thanks the idea "KA51O"!

    Anyway, in the meantime I have found a solution :)

    (MainWindow::)addToolBarBreak(Qt::LeftToolBarArea);


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.