[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"));
    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"));
    connect(boldAction, SIGNAL(triggered()), this, SLOT(onClickBold()));

    //add more actions

    widgetLayout->setContentsMargins(0, 0, 0, 0);

  • Thanks the idea "KA51O"!

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


Log in to reply

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