Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get more selectable options by clicking on a option
QtWS25 Last Chance

Get more selectable options by clicking on a option

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 3 Posters 849 Views
  • 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.
  • D Offline
    D Offline
    developer_61
    wrote on last edited by
    #3

    @jsulm yeah but im using a toolbar. So it is possible to click on a element on the toolbar to get the menu?

    jsulmJ 1 Reply Last reply
    0
    • D developer_61

      @jsulm yeah but im using a toolbar. So it is possible to click on a element on the toolbar to get the menu?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @developer_61 What about https://doc.qt.io/qt-5/qtoolbutton.html#setMenu ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • D Offline
        D Offline
        developer_61
        wrote on last edited by
        #5

        @jsulm i think wouldn't work. i mean i have a QTtoolbar with QTactions in it.
        So i need a method for QTactions.

        B 1 Reply Last reply
        0
        • D developer_61

          @jsulm i think wouldn't work. i mean i have a QTtoolbar with QTactions in it.
          So i need a method for QTactions.

          B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #6

          @developer_61
          You can add a QToolButton to a QToolBar by QAction *QToolBar::addWidget(QWidget *widget).
          That's very common.
          I happen to have some sample code.

              QMenu* menu = new QMenu(this);
              QAction* subAct1 = new QAction(QStringLiteral("SubAction1"));
              QAction* subAct2 = new QAction(QStringLiteral("SubAction2"));
              menu->addAction(subAct1);
              menu->addAction(subAct2);
          
              QToolButton* toolButton = new QToolButton(ui->toolBar);
              toolButton->setText(QStringLiteral("More"));
              toolButton->setMenu(menu);
              toolButton->setPopupMode(QToolButton::InstantPopup);
              ui->toolBar->addWidget(toolButton);
          
          1 Reply Last reply
          1
          • D Offline
            D Offline
            developer_61
            wrote on last edited by
            #7

            @Bonnie thank you very much. And it is possible to do that without coding? so directly in the qt designer?

            B 1 Reply Last reply
            0
            • D developer_61

              @Bonnie thank you very much. And it is possible to do that without coding? so directly in the qt designer?

              B Offline
              B Offline
              Bonnie
              wrote on last edited by
              #8

              @developer_61
              Unfortunately I think that's not possible.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                developer_61
                wrote on last edited by
                #9

                @Bonnie yeah cause i try to add a tool button to the tool bar but thats not possible. Only Qactions is allowed.
                But anyway thank you very much !

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  developer_61
                  wrote on last edited by developer_61
                  #10

                  another question ... @Bonnie
                  is it possible to hide that arrow next to the text
                  ec94cae2-8e04-4b2a-b922-68d37c11b61e-image.png

                  B 1 Reply Last reply
                  0
                  • D developer_61

                    another question ... @Bonnie
                    is it possible to hide that arrow next to the text
                    ec94cae2-8e04-4b2a-b922-68d37c11b61e-image.png

                    B Offline
                    B Offline
                    Bonnie
                    wrote on last edited by
                    #11

                    @developer_61
                    That's a frequently asked question :)
                    The easiest way is to use stylesheet.

                    toolButton->setStyleSheet("QToolButton::menu-indicator { image: none; }");
                    
                    1 Reply Last reply
                    1
                    • D Offline
                      D Offline
                      developer_61
                      wrote on last edited by
                      #12

                      @Bonnie thank you !!!
                      One last question:
                      is it possible to make an icon instad of more ?

                      B 1 Reply Last reply
                      0
                      • D developer_61

                        @Bonnie thank you !!!
                        One last question:
                        is it possible to make an icon instad of more ?

                        B Offline
                        B Offline
                        Bonnie
                        wrote on last edited by
                        #13

                        @developer_61
                        Of course!
                        Just use toolButton->setIcon(...) (maybe also with toolButton->setIconSize(...)) instead of toolButton->setText(...).
                        It has the same functions as a QToolButton in the designer.

                        1 Reply Last reply
                        1
                        • D Offline
                          D Offline
                          developer_61
                          wrote on last edited by
                          #14

                          @Bonnie thank you !!

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved