Results 1 to 2 of 2

Thread: QAction text color (QMenu)

  1. #1
    Join Date
    Jan 2009
    Posts
    17
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QAction text color (QMenu)

    Hello

    I would like to set the text (foreground) color of an QAction on a QMenu.
    I don't find out how that works.

    Best Regards
    Stefan

  2. #2
    Join Date
    Mar 2009
    Posts
    25
    Thanked 2 Times in 2 Posts

    Default Re: QAction text color (QMenu)

    One possible way. The idea below is to use a widget as a menu item, so that the text property can be customized.

    Qt Code:
    1. QWidgetAction *newAct = new QWidgetAction(this);
    2. QLabel *label = new QLabel(tr("New"));
    3. label->setStyleSheet("color: red");
    4. newAct->setDefaultWidget(label);
    5. newAct->setShortcuts(QKeySequence::New);
    6. newAct->setStatusTip(tr("Create a new file"));
    7. connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
    To copy to clipboard, switch view to plain text mode 

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

    StefanK (23rd March 2009)

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Match the text beetween two string
    By dreamer in forum Qt Programming
    Replies: 4
    Last Post: 20th May 2008, 14:48
  3. getting QAction text from the slot
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 18th April 2008, 13:03
  4. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  5. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30

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.