Results 1 to 3 of 3

Thread: A Photoshop-like Toolbar

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

    Default A Photoshop-like Toolbar

    I've tried using QMenu, to generate a list of options like in photoshop toolbar, but I failed to assign the action is selected as visible action in the toolbar or properly mark the last action selected.

    If you do not understand what I mean I want to do what you see in this video between 2:05 and 2:20 minutes:

    https://www.youtube.com/watch?v=W0nzWANu9UE

    Hopefully somebody can help me.

    Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,630
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: A Photoshop-like Toolbar

    Qt Code:
    1. // Can check the menu items
    2. QAction *actionA = new QAction("AAA", this);
    3. actionA->setCheckable(true);
    4. QAction *actionB = new QAction("BBB", this);
    5. actionB->setCheckable(true);
    6. QAction *actionC = new QAction("CCC", this);
    7. actionC->setCheckable(true);
    8. // only one at a time
    9. QActionGroup *group = new QActionGroup(this);
    10. group->setExclusive(true);
    11. group->addAction(actionA);
    12. group->addAction(actionB);
    13. group->addAction(actionC);
    14. // build a menu of them
    15. QMenu *menu = new QMenu(this);
    16. menu->addAction(actionA);
    17. menu->addAction(actionB);
    18. menu->addAction(actionC);
    19. // and a tool button to put the menu on
    20. QToolButton *button = new QToolButton(this);
    21. button->setDefaultAction(actionA);
    22. button->setMenu(menu);
    23. connect(menu, SIGNAL(triggered(QAction*)), button, SLOT(setDefaultAction(QAction*))); // << magic sauce
    24. // put it on the tool bar
    25. QToolBar *toolBar = new QToolBar(this);
    26. toolBar->addWidget(button);
    27. addToolBar(Qt::TopToolBarArea, toolBar);
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: A Photoshop-like Toolbar

    Thank you so much for your help!!

    I add this:

    Qt Code:
    1. button->setPopupMode(QToolButton::MenuButtonPopup);
    To copy to clipboard, switch view to plain text mode 

    In order to add a indepedent arrow button, to show the menu.

    Again Thanks you so much

Similar Threads

  1. Photoshop designed element to Qt
    By Nyte in forum Newbie
    Replies: 3
    Last Post: 6th February 2013, 12:01
  2. Replies: 0
    Last Post: 21st February 2012, 02:45
  3. Photoshop filter plug-in
    By ExxEnos in forum Qt Programming
    Replies: 19
    Last Post: 13th April 2010, 15:17
  4. Tool bar as photoshop, where only one is selected.
    By ricardo in forum Qt Programming
    Replies: 6
    Last Post: 23rd June 2009, 15:09
  5. Photoshop-like palettes.
    By Valeriy in forum Qt Programming
    Replies: 4
    Last Post: 1st September 2008, 21:37

Tags for this Thread

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.