Results 1 to 10 of 10

Thread: Two icons for each item in QMenu?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Two icons for each item in QMenu?

    Try calling setStyle() on your menu, with a style defined like this:

    Qt Code:
    1. class myStyle: public QPlastiqueStyle
    2. {
    3. Q_OBJECT
    4. public:
    5. int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const
    6. {
    7. if (metric == QStyle::PM_SmallIconSize)
    8. return 32; // default is 16
    9. else
    10. return QPlastiqueStyle::pixelMetric(metric, option, widget);
    11. }
    12. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2006
    Location
    Poland
    Posts
    35
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Two icons for each item in QMenu?

    @drhex

    This works fine, however it changes the style of the menu making the application looking bad.

    It seems icon size depends on the style and how it decides to draw it. And only QPlastiqueStyle respects PM_SmallIconSize value.

  3. #3
    Join Date
    Nov 2006
    Location
    Poland
    Posts
    35
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Lightbulb Re: Two icons for each item in QMenu?

    I have created WideIconsMenu class that should solve this problem.

    It uses ProxyStyle for Qt4 from QtCentre's wiki, and similar class for Qt3. Both Qt3 and Qt4 are supported.

    Multiple icons cannot be used, however WideIconsMenu draws the icons on its own, so icons of any width are supported. Everything you have to do is to compose an icon from several images.
    See included examples for more details.

    The code is available under GPLv3 license.

    If you find a bug, or have a suggestions, please send me an email.
    Attached Files Attached Files

  4. #4
    Join Date
    Nov 2006
    Location
    Poland
    Posts
    35
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Lightbulb Re: Two icons for each item in QMenu?

    Since Qt 4.6 and above provides QProxyStyle class, the ProxyStyle code is no longer needed.

    The attached archive contains 3 versions of WideIconsMenu:
    - for Qt 3 (no changes)
    - for Qt 4.x (no changes)
    - for Qt 4.6+ (new)
    Attached Files Attached Files

Similar Threads

  1. Making icons in QMenu Bigger?
    By pherthyl in forum Qt Programming
    Replies: 1
    Last Post: 28th October 2008, 07:54
  2. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07: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
  •  
Qt is a trademark of The Qt Company.