Results 1 to 6 of 6

Thread: QStackedwidget stylesheet problem

  1. #1
    Join Date
    Jan 2013
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QStackedwidget stylesheet problem

    I have QStackedwidget in my application, In the first page, i have tablewidget.
    i want to set stylesheet for Qtablewidget headerview.
    but i can't able to set stylesheet.

    I have tried following ways,

    this->setStyleSheet(
    " QHeaderView::section {"
    " background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
    " stop:0 #616161, stop: 0.5 #505050,"
    " stop: 0.6 #434343, stop:1 #656565);"
    " color: white;"
    " padding-left: 4px;"
    " border: 1px solid #6c6c6c;"
    "}");

    this->setStyleSheet( QStackedWidget QWidget#page { "
    " QHeaderView::section {"
    " background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
    " stop:0 #616161, stop: 0.5 #505050,"
    " stop: 0.6 #434343, stop:1 #656565);"
    " color: white;"
    " padding-left: 4px;"
    " border: 1px solid #6c6c6c;"
    "}"
    "}");

    but it is not working.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QStackedwidget stylesheet problem

    A solution is already posted in your earlier thread LINK

    Let me put it again

    Qt Code:
    1. this->setStyleSheet( QStackedWidget QWidget#page { " //<<<<<<<< Remove '{'
    2. " QHeaderView::section {"
    3. " background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
    4. " stop:0 #616161, stop: 0.5 #505050,"
    5. " stop: 0.6 #434343, stop:1 #656565);"
    6. " color: white;"
    7. " padding-left: 4px;"
    8. " border: 1px solid #6c6c6c;"
    9. "}" //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Remove '}'
    10. "}");
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2013
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QStackedwidget stylesheet problem

    sorry, this solution is not working. i have tried already

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QStackedwidget stylesheet problem

    Then there is some else we should be knowing.

    How are you creating the Ui
    1. If you are using the designer, then make sure the QWidget's name is correct and the stylesheet is applied to a containing widget.
    2. If you are creatig the using code, even then make sure the QWidget's name is correct.

    The folloing code works on my windows

    Qt Code:
    1. #include <QtGui>
    2. #include <QApplication>
    3.  
    4. QWidget * createPage(const QString & name)
    5. {
    6. QTableWidget * tableWidget = new QTableWidget;
    7. tableWidget->setObjectName(name);
    8. tableWidget->setRowCount(10);
    9. tableWidget->setColumnCount(10);
    10. return tableWidget;
    11. }
    12.  
    13. int main(int argc, char *argv[])
    14. {
    15. QApplication app(argc, argv);
    16.  
    17. QStackedWidget stackedWidget;
    18. stackedWidget.showMaximized();
    19.  
    20. stackedWidget.addWidget(createPage("Page1"));
    21. stackedWidget.addWidget(createPage("Page2"));
    22.  
    23. stackedWidget.setStyleSheet(
    24. "QStackedWidget QTableWidget#Page1 QHeaderView::section {"
    25. " background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
    26. " stop:0 #616161, stop: 0.5 #505050,"
    27. " stop: 0.6 #434343, stop:1 #656565);"
    28. " color: white;"
    29. " padding-left: 4px;"
    30. " border: 1px solid #6c6c6c;"
    31. "}"
    32. "QStackedWidget QTableWidget#Page2 QHeaderView::section {"
    33. " background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
    34. " stop:0 #red, stop: 0.5 #green,"
    35. " stop: 0.6 #green, stop:1 #pink);"
    36. " color: white;"
    37. " padding-left: 4px;"
    38. " border: 1px solid #bule;"
    39. "}");
    40.  
    41. stackedWidget.setCurrentIndex(0);
    42. // stackedWidget.setCurrentIndex(1);
    43.  
    44. return app.exec();
    45. }
    To copy to clipboard, switch view to plain text mode 

    If still it does not work, you better post a small compilable code with the problem
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QStackedwidget stylesheet problem

    What are you trying to do?

    By the way, are we sure QStackedWidget has a headerview?

    You may also give it a try from the qt designer.

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QStackedwidget stylesheet problem

    What are you trying to do?

    By the way, are we sure QStackedWidget has a headerview?
    OP is trying to apply the style for headerview of the QTableWidget which is in a QStackedWidget. As I understand style should only apply to QTableWidgets in the QStackedWidget, and not the other QTableWidgets outside QStackedWidget.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. QStackedWidget Problem
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2011, 12:13
  2. problem with QStackedwidget
    By psantofe in forum Qt Programming
    Replies: 3
    Last Post: 14th April 2010, 13:41
  3. QStackedWidget layout problem
    By Banjo in forum Qt Programming
    Replies: 9
    Last Post: 15th May 2008, 01:15
  4. QStackedWidget fill Postscript image And scroll problem
    By patrik08 in forum Qt Programming
    Replies: 11
    Last Post: 22nd April 2007, 10:30
  5. Stylesheet (css) problem
    By madcama in forum Newbie
    Replies: 1
    Last Post: 4th December 2006, 23:41

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.