Results 1 to 2 of 2

Thread: Trouble setting toolbar widget palette

  1. #1
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Trouble setting toolbar widget palette

    Hello!

    My program has a mainwindow with a number of toolbars. I want to add a toolbar that contains a QLabel displaying some text and would like the text to be, let's say, red.

    What i'm doing:
    Qt Code:
    1. MyWindow::MyWindow()
    2. {
    3. QToolBar* tb = new QToolBar(this);
    4.  
    5. QLabel* label = new QLabel;
    6. QPalette palette = label->palette();
    7. palette.setColor(QPalette::WindowText, QColor("#FF0000"));
    8. label->setPalette(palette);
    9. label->setText("wo0t");
    10.  
    11. tb->addWidget(label);
    12. this->addToolBar(QT::TopToolBarArea, tb);
    13. }
    To copy to clipboard, switch view to plain text mode 

    What i'm expecting: the toolbar text to be red.
    What i'm getting: the toolbar text is not changing, at all.

    Any thoughts? What am I doing wrong? Should I maybe set the text and the palette after construction has finished?

  2. #2
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Trouble setting toolbar widget palette

    Further testing reveals that the problem is confined to certain window styles, ex: CDE, Motif and Cleanlooks.

    Also, setting the palette of a label anywhere that isn't in a toolbar seems to work ok, regardless of the style.

    Should this behavior be considered a bug or a feature?
    Last edited by TheRonin; 9th December 2009 at 17:09.

Similar Threads

  1. Replies: 10
    Last Post: 10th November 2010, 03:12
  2. Trouble while viewing a created a toolbar!!
    By aditya.kaole in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2009, 21:04
  3. Widget Palette
    By QbelcorT in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2009, 16:17
  4. Palette toolbar need help plz...
    By Radagast in forum Qt Programming
    Replies: 4
    Last Post: 28th July 2008, 14:08
  5. Palette toolbar
    By Radagast in forum Qt Programming
    Replies: 8
    Last Post: 7th July 2008, 17:56

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.