Results 1 to 5 of 5

Thread: Change the background color for the QAction's of QMenu

  1. #1
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Change the background color for the QAction's of QMenu

    Hi all,

    I've placed this css code in the styleSheet property of the QMenu object:

    Qt Code:
    1. {
    2. background-color: red;
    3. }
    To copy to clipboard, switch view to plain text mode 

    But the color hasn't changed. Is it possible to change the background color?

    Kind regards.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Change the background color for the QAction's of QMenu

    Apply stylesheet to QMenu (not QAction).
    Qt Code:
    1. {
    2. background-color: red;
    3. }
    To copy to clipboard, switch view to plain text mode 

    QAction is not a QWidget, i.e. it does not have visual re-presentation so stylesheets do not apply to it.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Change the background color for the QAction's of QMenu

    But this code applies to all the options in QMenu. Is it possible that applies only to one option?

    Kind regards.

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Change the background color for the QAction's of QMenu

    No you can only apply to the QMenu as a whole (i.e. all the options), individual action/item styles is not possible.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Change the background color for the QAction's of QMenu

    Ok.

    Best regards!

Similar Threads

  1. Change background color of a QStackWidget
    By fiodis in forum Newbie
    Replies: 1
    Last Post: 14th December 2012, 08:19
  2. Replies: 1
    Last Post: 17th August 2010, 16:17
  3. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 07:14
  4. how to change background color of QMenu??
    By anupamgee in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2009, 12:41
  5. QAction text color (QMenu)
    By StefanK in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2009, 15:14

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.