Results 1 to 7 of 7

Thread: ToolBar with menus and "effects"

  1. #1
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Red face ToolBar with menus and "effects"

    Well, I have my code with a toolbar with QMenus, each QMenu has several options; I want that when push to one of them option the icon of whom they pushed go to icon of button of the QMenu and whenever they press this button, go directly to that function with that icon.

    Sorry for my bad english

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: ToolBar with menus and "effects"

    Oh, that's easy. Just assign the QAction associated with the menu entry directly to the button (it has to be a QToolButton not a QPushButton) using QToolButton::setDefaultAction().

  3. The following user says thank you to wysota for this useful post:

    avis_phoenix (19th June 2006)

  4. #3
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Red face Re: ToolBar with menus and "effects"

    Sorry; but i don't understand how use a Qtoolbutton .

    For example, my code is more o less like...

    QToolBar Bar;
    QMenu Menu;
    ....
    {
    ...
    Menu = new QMenu("File");
    Menu->setIcon(Icon);
    Menu->addAction(Action);
    Menu->AddAction(Action2);
    ...
    ...
    Bar = addToolBar("My Bar");
    Bar->addAction(Menu->action());
    ...
    }

    I don´t remember exactly my code, but i don't use a Qtoolbutton, the buttons are my QMenus in my toolbar, i can´t see how use a propiety of QToolButton, or my toolbar use my Qmenu like QToolButtons?
    or i write my previous question incomplete?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: ToolBar with menus and "effects"

    Oh, ok. So it's even easier. Just remove the menu action from the toolbar and add an action associated with one of its entries.

    Edit: Sorry... but QMenu doesn't have an "action()" method. Are you sure this is really your code?
    Last edited by wysota; 25th May 2006 at 16:52.

  6. #5
    Join Date
    Jan 2006
    Location
    South Carolina, USA
    Posts
    34
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ToolBar with menus and "effects"

    Quote Originally Posted by avis_phoenix
    Well, I have my code with a toolbar with QMenus, each QMenu has several options; I want that when push to one of them option the icon of whom they pushed go to icon of button of the QMenu and whenever they press this button, go directly to that function with that icon.

    Sorry for my bad english
    I am not sure what you are asking.. Are you asking how to get a menu to popup when you push a button on the toolbar?

    Michael

  7. #6
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: ToolBar with menus and "effects"

    Michael , no, i have a toolbar with buttons with a popup menu, i want when press a item of menu change the icon of this menu in toolbar.

    wysota, the code use Menu->defaultAction () ;

  8. #7
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: ToolBar with menus and "effects"

    I didn't write well the code is menu->menuAction(), i.e:
    {
    ...
    barra->addAction(Menu->menuAction());
    ...
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.