Results 1 to 2 of 2

Thread: Change QWidget Title Color

  1. #1
    Join Date
    Apr 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Change QWidget Title Color

    I have a custom class called Window that extends QWidget.

    Qt Code:
    1. #include "window.h"
    2.  
    3. // This is the base that all (MDI) sub-windows extend off
    4.  
    5. Window::Window()
    6. {
    7. // Add fake icon to remove icon in all
    8. setWindowIcon(QIcon("."));
    9. }
    10.  
    11. void Window::paintEvent(QPaintEvent *)
    12. {
    13. opt.init(this);
    14. QPainter p(this);
    15. style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
    16. }
    To copy to clipboard, switch view to plain text mode 

    css:

    Qt Code:
    1. QWidget:title
    2. {
    3. background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #ca0619);
    4. }
    To copy to clipboard, switch view to plain text mode 

    When I do this the buttons (minimize, maximize and close) disappear (as seen in the picture below).

    C3egU.jpg

    So my question, how do I properly style my Window titlebar?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Change QWidget Title Color

    Well, unfortunately, it is not as easy as you think. For an introduction have a look at http://www.qt-coding.com/2013/08/01/...s-and-buttons/

Similar Threads

  1. Tab Title Color
    By Qt52 in forum Newbie
    Replies: 4
    Last Post: 22nd May 2013, 09:02
  2. Replies: 3
    Last Post: 22nd January 2010, 16:46
  3. How to set color for QGroupBox Title
    By arunvv in forum Qt Programming
    Replies: 5
    Last Post: 4th December 2008, 17:50
  4. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25
  5. Title Bar Color
    By kaaty in forum Qt Programming
    Replies: 1
    Last Post: 8th December 2006, 16:32

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.