I've my widget "MeasurePanel" inherited from QWidget:
Code:
{ Q_OBJECT Q_PROPERTY (int value READ value WRITE setValue) public: ...
At design time I added CSS to it (and it's displayed correctly @ designer):
Code:
QWidget#MeasurePanel{ border-width: 3px; border-style: inset; border-color: #000000; border-radius: 9px; background-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 rgba(116, 38, 116, 255), stop:0.99115 rgba(239, 0, 239, 255)); }
In main application I've :
Code:
MeasurePanel* panels[4]; ... panels[0] = new MeasurePanel(this); //panels[0]->setObjectName("MeasurePanel"); qDebug() << panels[0]->objectName(); // panels[0]->setStyleSheet("MeasurePanel#MeasurePanel{border-width: 3px; border-style: inset; border-color: #000000; border-radius: 9px;}"); ui->gridLayout->addWidget(panels[0],1,0);
But after this CSS isn't displayed. I checked ObjectName (commented), and it's "MeasurePanel". I've tried CSS in different forms:
- QWidget#MeasurePanel
- QWidget > MeasurePanel
- MeasurePanel#MeasurePanel
But still can't get it working.
Addition :
tried this one :
Code:
panels[0]->setProperty("MeasurePanel", true); panels[0]->setStyleSheet("*[MeasurePanel=\"true\"]{border-width: 3px; border-style: inset; border-color: #000000;}");
Same thing.
Another addition:
I put everything inside QFrame and now I'm able to edit that frame CSS, but still can't modify Widget CSS.
