Results 1 to 1 of 1

Thread: No CSS in child class

  1. #1
    Join Date
    Jan 2011
    Posts
    11
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question No CSS in child class

    I've my widget "MeasurePanel" inherited from QWidget:
    Qt Code:
    1. class MeasurePanel : public QWidget
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY (int value READ value WRITE setValue)
    5. Q_PROPERTY (QColor fontColor READ fontColor WRITE setFontColor)
    6.  
    7.  
    8. public:
    9. explicit MeasurePanel(QWidget *parent = 0);
    10. ...
    To copy to clipboard, switch view to plain text mode 

    At design time I added CSS to it (and it's displayed correctly @ designer):
    Qt Code:
    1. QWidget#MeasurePanel{
    2. border-width: 3px;
    3. border-style: inset;
    4. border-color: #000000;
    5. border-radius: 9px;
    6.  
    7. 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));
    8. }
    To copy to clipboard, switch view to plain text mode 

    In main application I've :
    Qt Code:
    1. MeasurePanel* panels[4];
    2. ...
    3. panels[0] = new MeasurePanel(this);
    4.  
    5. //panels[0]->setObjectName("MeasurePanel");
    6.  
    7. qDebug() << panels[0]->objectName();
    8. // panels[0]->setStyleSheet("MeasurePanel#MeasurePanel{border-width: 3px; border-style: inset; border-color: #000000; border-radius: 9px;}");
    9. ui->gridLayout->addWidget(panels[0],1,0);
    To copy to clipboard, switch view to plain text mode 

    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 :
    Qt Code:
    1. panels[0]->setProperty("MeasurePanel", true);
    2. panels[0]->setStyleSheet("*[MeasurePanel=\"true\"]{border-width: 3px; border-style: inset; border-color: #000000;}");
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by kartun; 2nd February 2011 at 14:47. Reason: updated contents

Similar Threads

  1. Handle child of QProcess's child.
    By gcubar in forum Newbie
    Replies: 4
    Last Post: 30th November 2012, 02:59
  2. Replies: 4
    Last Post: 17th January 2011, 14:05
  3. Replies: 7
    Last Post: 22nd September 2010, 00:32
  4. Replies: 3
    Last Post: 27th December 2008, 19:34
  5. Replies: 3
    Last Post: 16th May 2007, 11:07

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.