Results 1 to 6 of 6

Thread: stylesheet not working correctly

  1. #1
    Join Date
    Jul 2012
    Posts
    23
    Thanks
    3

    Default stylesheet not working correctly

    hello guys
    I was make custom frame and I have to decorate them using stylesheet.
    my custom frame has title bar and main widget.
    and I hope paint to blue only title bar not main widget.
    but is not working...........

    first, my custom frame is organized like this :
    Qt Code:
    1. Frame::Frame()
    2. {
    3. m_titleBar = new TitleBar(this);
    4. m_content = new QWidget(this);
    5.  
    6. QVBoxLayout *vbox = new QVBoxLayout(this);
    7. vbox->addWidget(m_titleBar);
    8.  
    9. QVBoxLayout *layout = new QVBoxLayout(this);
    10. layout->addWidget(m_content);
    11.  
    12. vbox->addLayout(layout);
    13. }
    14.  
    15. TitleBar::TitleBar(QWidget* parent)
    16. : QWidget(parent)
    17. {
    18. QLabel *label = new QLabel(this);
    19. label->setText("mylabel");
    20.  
    21. QHBoxLayout *hbox = new QHBoxLayout(this);
    22.  
    23. hbox->addWidget(label);
    24. }
    To copy to clipboard, switch view to plain text mode 

    and I was try some method this :
    Qt Code:
    1. titlebar->setobjectname("titlebar");
    2. customframe->setstylesheet(tr("QWidget#titlebar{background : red;}"));
    To copy to clipboard, switch view to plain text mode 

    and this :
    Qt Code:
    1. titlebar->setstylesheet(tr("QWidget{background : red;"}))
    To copy to clipboard, switch view to plain text mode 

    It's so hard... please help me ...

  2. #2
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet not working correctly

    try this--->
    Qt Code:
    1. label->setStyleSheet("QLabel{background : red;}");
    To copy to clipboard, switch view to plain text mode 
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  3. #3
    Join Date
    Jul 2012
    Posts
    23
    Thanks
    3

    Default Re: stylesheet not working correctly

    I was also try that..
    but I don't want colored label.
    I want paint whole title bar..
    how?..

  4. #4
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet not working correctly

    what it means :-

    paint whole title bar
    I didnt understand your ques.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  5. #5
    Join Date
    Jul 2012
    Posts
    23
    Thanks
    3

    Default Re: stylesheet not working correctly

    I'm going to explain you..

    My custom frame is like this :

    1.png

    and your answer is this.
    2.png

    but I want to method to paint this..
    3.png

  6. #6
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet not working correctly

    See this example:--->
    TitleBarPainting.zip
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  7. The following user says thank you to sonulohani for this useful post:

    melody:p (5th September 2012)

Similar Threads

  1. setTabStopWidth not working correctly?
    By Kyosaur in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2012, 14:16
  2. Replies: 0
    Last Post: 28th April 2010, 16:44
  3. Replies: 1
    Last Post: 19th March 2009, 13:40
  4. Drop not working correctly
    By rippa in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2008, 15:13
  5. renderText is not working correctly
    By validator in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2008, 16:55

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.