Results 1 to 1 of 1

Thread: Problem in getting proper visibility state of the widget when using Stylesheet

  1. #1
    Join Date
    Oct 2013
    Location
    Everett WA USA
    Posts
    12
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Problem in getting proper visibility state of the widget when using Stylesheet

    Dear Experts,

    I am working on an application where in which the MainWidget (Custom class of QWidget) will be the parent widget of all other widgets.

    I am creating the child widgets named ChildWidget(Custom class of QWidget) *dynamically* and adding these child widgets into parent's widget's stack in the order which my system impose. (That means stacking order of these child widgets are controlled by my application which is an requirement of my application). Each child widget will have its own visibility state based on the widgets shown on the screen.

    Based on some suggestions given by the experts in the below threads (posted by me), my application is working as expected.

    http://www.qtcentre.org/threads/5660...-child-widgets

    http://www.qtcentre.org/threads/5657...tially-visible

    Earlier I was using QPalette to set the background color of both MainWidget and its child widgets (ChildWidget)
    Qt Code:
    1. #include <QtGui/QWidget>
    2. #include <QtGui/QPalette>
    3.  
    4. class MainWidget
    5. {
    6. ---
    7. --
    8.  
    9. private:
    10. QPalette m_palette;
    11. };
    12.  
    13. class ChildWidget : public QWidget
    14. {
    15. public:
    16. ChildWidget(MainWidget* pParent);
    17. ---
    18. ---
    19. private:
    20. QPalette m_palette;
    21. };
    22.  
    23.  
    24. MainWidget::MainWidget(QWidget* pParent) : QWidget(pParent), m_palette(QPalette())
    25. {
    26. ----
    27. m_palette.setColor(QPalette::Background, Qt::white);
    28. setAutoFillBackground(true);
    29. setPalette(m_palette);
    30. }
    31.  
    32. ChildWidget::ChildWidget(MainWidget* pParent) : MainWidget(pParent), m_palette(QPalette())
    33. {
    34. ----
    35. m_palette.setColor(QPalette::Background, Qt::white);
    36. setAutoFillBackground(true);
    37. setPalette(m_palette);
    38. }
    To copy to clipboard, switch view to plain text mode 


    Note: With our current system design the visibility state of each child widget (Refer to above link on Visibility state) has the dependency on the background-color set on it.


    Now I am planning to create the MainWidget and ChildWidget using Qt Designer and set the background-color for MainWidget using the style sheet.


    Open MainWidget.ui ->Right click on the MainWidget->Change Stylesheet -> select the back ground color -> apply & say OK -> save MainWidget.ui


    Here are my questions:
    a. Is there a way to apply the common style sheet at the parent widget level (for ex MainWidget) so that it applies all its child widgets of type (ChildWidget) without altering their visibility state?
    b. How do I know that style sheet data is propagated from parent widget to child widgets?

    Thanking You,

    Regards
    SRaju
    Last edited by sraju; 2nd July 2014 at 01:42. Reason: updated contents

Similar Threads

  1. How to update layout after widget visibility change ?
    By phenoboy in forum Qt Programming
    Replies: 6
    Last Post: 10th September 2013, 11:27
  2. Replies: 2
    Last Post: 9th December 2010, 15:11
  3. Replies: 3
    Last Post: 17th March 2010, 17:47
  4. Qtable visibility problem
    By jano_alex_es in forum Newbie
    Replies: 0
    Last Post: 21st May 2009, 12:51
  5. [QT4] Saving a widget state
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2006, 15:31

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.