Details
-
Bug
-
Resolution: Fixed
-
P4: Low
-
4.5.3, 4.6.1, 4.6.2, 4.6.3, 5.5.0
-
None
Description
It should be possible to set a stylesheet on a QDockWidget where it will be applied both when docked and floating, however it seems that currently when setting a stylesheet on a QDockWidget that it will only be applied when that QDockWidget is floating. Either the styling of this widget should be consistent or the correct way for styling a docked QDockWidget should be documented.
The following example demonstrates this issue:
#include <QtGui> #include <QApplication> class DockContent : public QWidget { public: DockContent () { QLabel* l1 = new QLabel ("Item Label 1"); QLabel* l2 = new QLabel ("Item Label 2"); QLabel* l3 = new QLabel ("Item Label 3"); QLabel* l4 = new QLabel ("Item Label 4"); QLabel* l5 = new QLabel ("Item Label 5"); QVBoxLayout* v1 = new QVBoxLayout(); v1->addWidget (l1); v1->addWidget (l2); v1->addWidget (l3); v1->addWidget (l4); v1->addWidget (l5); QSpacerItem* verticalSpacer = new QSpacerItem(20, 363, QSizePolicy::Minimum, QSizePolicy::Expanding); v1->addItem(verticalSpacer); setLayout (v1); } }; class DockWidget :public QDockWidget { public: DockWidget () { setObjectName ("Dock_Widget"); dockContent = new DockContent(); dockContent->setObjectName("dock_content"); setWidget(dockContent); setFixedSize (160,600); } private: DockContent *dockContent; }; class MainWindow : public QMainWindow { public: MainWindow () { DockWidget* d = new DockWidget (); addDockWidget (Qt::LeftDockWidgetArea, d); QTableWidget* w = new QTableWidget (600, 5); setCentralWidget (w); setFixedSize (600,600); this->centralWidget()->setStyleSheet ( "QDockWidget#Dock_Widget{ border-radius:6px ; \ border:1px solid rgba(237, 237, 237, 255); \ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0.856444 rgba(214, 214, 214, 255), \ stop:0.950888 rgba(255, 255, 255, 255), stop:0.980424 rgba(217, 217, 217, 255))}"); } }; int main (int n, char** c) { QApplication app (n,c); MainWindow w; w.show (); app.setStyleSheet ( "QDockWidget{ border-radius:6px ; \ border:1px solid rgba(237, 237, 237, 255); \ background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0.856444 rgba(214, 214, 214, 255), \ stop:0.950888 rgba(255, 255, 255, 255), stop:0.980424 rgba(217, 217, 217, 255))}"); return app.exec (); }