Results 1 to 8 of 8

Thread: QPalette Question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPalette Question

    Quote Originally Posted by jlgerber View Post
    Eh? I am talking about the frame itself. It is a QGroupBox (creates a frame and label around other widgets).
    OK, so we are talking about the frame in sense of a line, not in sense of QFrame.

    Quote Originally Posted by jlgerber View Post
    And the problem isnt that i cannot see it; the problem is that it does not respond to changes in the application palette, like every other widget in the program.
    Consider this program:
    Qt Code:
    1. #include <QApplication>
    2. #include <QGroupBox>
    3. #include <QLayout>
    4. #include <QPalette>
    5. #include <QPushButton>
    6.  
    7. class Test : public QGroupBox
    8. {
    9. Q_OBJECT
    10. public:
    11. Test() : QGroupBox( "test" )
    12. {
    13. QPushButton *b = new QPushButton( "change" );
    14.  
    15. connect( b, SIGNAL( clicked() ), this, SLOT( changePalette() ) );
    16.  
    17. l->addWidget( b );
    18. setLayout( l );
    19. }
    20.  
    21. private slots:
    22. void changePalette()
    23. {
    24. p.setColor( QPalette::Dark, Qt::red );
    25. QApplication::setPalette( p );
    26. update();
    27. }
    28. };
    29.  
    30. int main( int argc, char **argv )
    31. {
    32. QApplication app( argc, argv );
    33.  
    34. Test t;
    35. t.show();
    36.  
    37. return app.exec();
    38. }
    39.  
    40. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    I've attached two screenshots showing group box with original palette and the same group box after the QApplication palette was changed.

    Note that some styles (in this case Plastique) sometimes ignore QPalette settings, so I had to use windows style.
    Attached Images Attached Images

Similar Threads

  1. QTextEdit simple question
    By Marcopolo in forum Qt Tools
    Replies: 4
    Last Post: 11th October 2007, 00:01
  2. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38
  3. Beginner C++ question
    By masoroso in forum General Programming
    Replies: 2
    Last Post: 19th April 2006, 14:15
  4. QPalette won't set QLabel's Window & Foreground color
    By koklim in forum Qt Programming
    Replies: 6
    Last Post: 23rd January 2006, 10:27
  5. xml with binary question
    By TheKedge in forum Qt Programming
    Replies: 7
    Last Post: 12th January 2006, 23:21

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.