Results 1 to 3 of 3

Thread: QStyledItemDelegate paint QPushButton with stylesheet

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QStyledItemDelegate paint QPushButton with stylesheet

    Hello,
    I struggle with painting QPushButton with inherited styleSheet in custom delegate.
    Delegate parent is TreeView with styleSheet.

    The way I paint it in my QStyledItemDelegate.

    Qt Code:
    1. void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    2. {
    3. pb_Style.state |= QStyle::State_Raised | QStyle::State_Enabled | option.state;
    4.  
    5. QRect pbRect = option.rect;
    6. ...
    7.  
    8. pb_Style.rect = pbRect;
    9. pb_Style.text = QString();
    10.  
    11. style->drawControl(QStyle::CE_PushButton, &pb_Style, painter, qobject_cast<QWidget *>(this->parent()) );
    12. }
    To copy to clipboard, switch view to plain text mode 

    In short I don't know how to paint QPushButton with inherited styleSheet from the view.
    Any suggestions are more then welcome.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QStyledItemDelegate paint QPushButton with stylesheet

    SOLVED:
    Paint actual widget does the trick, my bad.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  3. #3
    Join Date
    Jul 2011
    Posts
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Post Re: QStyledItemDelegate paint QPushButton with stylesheet

    Quote Originally Posted by Talei View Post
    SOLVED:
    Paint actual widget does the trick, my bad.
    Can you explain exactly what you mean by this? Perhaps with an example?

    I am seeing a similar problem with a QProgressBar not being painted with the stylesheet set on my QTreeWidget within my QStyledItemDelegate even though the stylesheet works fine for true QProgressBar widgets.

Similar Threads

  1. QTableView paint row in stylesheet hover
    By estanisgeyer in forum Qt Programming
    Replies: 3
    Last Post: 23rd October 2012, 09:17
  2. Paint selection in QStyledItemDelegate's subclass
    By woodtluk in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2012, 15:51
  3. Custom QStyledItemDelegate paint function never called
    By mattsnowboard in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2011, 01:57
  4. QPushButton stylesheet problem
    By blukske in forum Qt Programming
    Replies: 10
    Last Post: 24th August 2009, 21:51
  5. QPushButton in QDockWidget loses stylesheet
    By martinb0820 in forum Qt Programming
    Replies: 5
    Last Post: 22nd June 2009, 18:23

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.