Results 1 to 5 of 5

Thread: QToolbutton:checked -> QIcon:selected not working

  1. #1
    Join Date
    Jul 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default QToolbutton:checked -> QIcon:selected not working

    I'm trying to show a specific icon when my qtoolbutton is checked - so far without success.

    My workflow:
    1. create a qmaindindow in qdesigner
    2. add a toolbar
    3. add an action and make it checkable
    4. add an icon to the action for all states (normal off/on, active off/on, selected off/on). All icons are in a resource file.
    5. test it.

    At first the default (normal) icon is shown. On mouseover the active icon is shown. So far so good. But when I click my qtoolbutton and it is in its checked state the active icon is shown again. Why is the active icon shown and not the selected icon? How can I change this behaviour?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QToolbutton:checked -> QIcon:selected not working

    please show us your code for 4.

  3. #3
    Join Date
    Jul 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QToolbutton:checked -> QIcon:selected not working

    I set the icons in qdesigner.

    But I also tried this:

    Qt Code:
    1. _asc_icon.addFile(":/Icons24/sort_asc_normal", QSize(24,24), QIcon::Normal, QIcon::On);
    2. _asc_icon.addFile(":/Icons24/sort_asc_active", QSize(24,24), QIcon::Active, QIcon::On);
    3. _asc_icon.addFile(":/Icons24/sort_asc_selected", QSize(24,24), QIcon::Selected, QIcon::On);
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QToolbutton:checked -> QIcon:selected not working

    Ah, selected != checked.. Selected means if your action has keyboard focus. I guess you have to use style sheets or subclass QAction.

  5. #5
    Join Date
    Jul 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QToolbutton:checked -> QIcon:selected not working

    Thats odd. But thx!

    I wrote my own QToolButton implementation (handling checkStateSet and nextCheckState) and it works fine now.

Similar Threads

  1. Which QCheckBox has been checked?
    By alexandernst in forum Newbie
    Replies: 2
    Last Post: 14th September 2009, 11:09
  2. Delete if row checked
    By wirasto in forum Qt Programming
    Replies: 2
    Last Post: 11th July 2009, 15:16
  3. TabOrder for QToolButton not working
    By gren15 in forum Qt Tools
    Replies: 6
    Last Post: 28th May 2009, 17:38
  4. Which QCheckBox is checked?
    By Craig.Smith in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2007, 15:52
  5. Replies: 2
    Last Post: 31st May 2006, 22:52

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.