Results 1 to 4 of 4

Thread: Problem to setstylesheet

  1. #1
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem to setstylesheet

    Hi all.
    I ve a problem. the following code i9s not working for me.

    Pointer->LoadStyleSheet("pagefold.qss");
    ui.m_pLowerStatusBar->setStyleSheet("QWidget#widget {background-color: blue}");

    Its loading the qss file only. inside it QWidget is gray. But there is a widget. itried to fill like 2nd line. But its not working.
    same code is working fine if i give like
    Pointer->LoadStyleSheet("default.qss");
    ui.m_pLowerStatusBar->setStyleSheet("QWidget#widget {background-color: blue}");

    Can any body help me?

    Thank you All.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  2. #2
    Join Date
    Dec 2006
    Location
    San Antonio, TX
    Posts
    9
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem to setstylesheet

    Are you ensuring that you are reading the file in as one long string before trying to set it? Normally the default.qss is blank so it probably would work in any case.

    Example extracted from ref: http://doc.trolltech.com/4.3/widgets...ditor-cpp.html

    Qt Code:
    1. void StyleSheetEditor::loadStyleSheet(const QString &sheetName)
    2. {
    3. QFile file(":/qss/" + sheetName.toLower() + ".qss");
    4. file.open(QFile::ReadOnly);
    5. QString styleSheet = QLatin1String(file.readAll());
    6.  
    7. ui.styleTextEdit->setPlainText(styleSheet);
    8. qApp->setStyleSheet(styleSheet);
    9. ui.applyButton->setEnabled(false);
    10. }
    To copy to clipboard, switch view to plain text mode 

    If you are using the qss from the resource (rcc), it might be helpful to ensure that you resource init it in your main as well ( Q_INIT_RESOURCE(resource name); ).

    Just a couple of things that come to mind.

  3. #3
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem to setstylesheet

    Quote Originally Posted by Junior View Post
    Are you ensuring that you are reading the file in as one long string before trying to set it? Normally the default.qss is blank so it probably would work in any case.

    Example extracted from ref: http://doc.trolltech.com/4.3/widgets...ditor-cpp.html

    Qt Code:
    1. void StyleSheetEditor::loadStyleSheet(const QString &sheetName)
    2. {
    3. QFile file(":/qss/" + sheetName.toLower() + ".qss");
    4. file.open(QFile::ReadOnly);
    5. QString styleSheet = QLatin1String(file.readAll());
    6.  
    7. ui.styleTextEdit->setPlainText(styleSheet);
    8. qApp->setStyleSheet(styleSheet);
    9. ui.applyButton->setEnabled(false);
    10. }
    To copy to clipboard, switch view to plain text mode 

    If you are using the qss from the resource (rcc), it might be helpful to ensure that you resource init it in your main as well ( Q_INIT_RESOURCE(resource name); ).

    Just a couple of things that come to mind.
    I think Q_INIT_RESOURCE is not so necessary. i ve posted a query in forumand got replied. Its also working.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  4. #4
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem to setstylesheet

    Hi All.
    I m still facing same problem.
    I ve a doubt. can i paint a specific area like follow.

    pointer->LoadStyleSheet("pagefold.qss");
    // Is it possible?
    ui.m_specificArea ->setStyleSheet("QWidget#specificArea {background-color: blue}");

    I ll thankful if any body let meknow.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

Similar Threads

  1. PyQt QTimer problem { FIXED }
    By WinchellChung in forum Newbie
    Replies: 0
    Last Post: 1st March 2008, 16:50
  2. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  3. QSpinBox and setStylesheet problem
    By Ace-X in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2007, 11:21
  4. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.