Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [solved] qtoolbar: one under the other

    General and Desktop
    2
    3
    1165
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      broadpeak last edited by

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

      1 Reply Last reply Reply Quote 0
      • K
        KA51O last edited by

        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);
        @

        1 Reply Last reply Reply Quote 0
        • B
          broadpeak last edited by

          Thanks the idea "KA51O"!

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

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post