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. Customize QAction
QtWS25 Last Chance

Customize QAction

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.1k 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.
  • S Offline
    S Offline
    Sorin
    wrote on last edited by
    #1

    Hello,

    I want to implement the following control : "image":http://img831.imageshack.us/img831/5137/testuvs.jpg . I made a QToolButton and I added a QMenu to it( this menu has a QAction ) but I don't know how to add to the QAction three widgets. I'm on the wrong track? Can you give me a suggestion on how should I implement this control?

    Thanks in advance!

    There are only 10 types of people in the world: Those who understand binary, and those who don't

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      You want a button with a drop-down menu in a toolbar?

      @QMenu *menu = new QMenu;

      menu->addAction(...);

      ...

      toolBar->addAction(menu->menuAction());@

      Update the menuAction() icon every time you change the current selection. It could be that you don't have to. That I didn't try that myself.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sorin
        wrote on last edited by
        #3

        Your solution didn't work for me, maybe because I didn't understand it very well, what I did was:

        @QToolButton* button = new QToolButton( parent );
        QMenu* menu = new QMenu( shapeButton );
        QToolBar* toolbar = new QToolBar( menu );
        QAction* a1 = new QAction( "test1",0 );
        QAction* a2 = new QAction( "test2",0 );
        QAction* fake = new QAction( " ",0 );

        menu->addAction( fake );
        toolbar->addAction( a1 );
        toolbar->addAction( a2 );
        button->setMenu( menu ); @

        There are only 10 types of people in the world: Those who understand binary, and those who don't

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          Have a look a the "Main window example":http://doc.qt.nokia.com/latest/demos-mainwindow.html, in particular "toolbar.cpp":http://doc.qt.nokia.com/latest/demos-mainwindow-toolbar-cpp.html.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          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