Results 1 to 3 of 3

Thread: Stylesheeting and QStyle::drawControl() - possible?

  1. #1
    Join Date
    Aug 2007
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Stylesheeting and QStyle::drawControl() - possible?

    Hello, guys!

    This time I want to draw a progress bar in one of QTreeView cells.
    Well, I already have the code which does this - just created my own QItemDelegate which uses QStyle::drawControl().

    And the question: I need that progress bar to be stylable. I mean - stylable with stylesheets.
    Is there a way to do so?

    Something like setting QApplication::setStylesheet("QProgressBar {...}")?
    First, I don't know if this'll work (I guess I should just try)
    Second - I don't want to apply this style to all of my progress bars, just the one rendered in QTreeView.

    Any hints, suggestions?
    Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Stylesheeting and QStyle::drawControl() - possible?

    Will that work? No idea.... should work, because style() should return a pointer to the stylesheet style if a stylesheet is applied. If it works, then try applying the stylesheet (with proper selectors) on the view widget or on the viewport widget. Assuming you don't have any real progress bar widgets in your view only the fake bars should be affected.

  3. #3
    Join Date
    Aug 2007
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Stylesheeting and QStyle::drawControl() - possible?

    In case you interested, this did not work
    I didn't investigate further - I tried and seen no results.
    So instead I just ended up using QProgressBar as a persistent editor - ala fake one - which doesn't actually used edit anything (it's a progress bar ).
    I just reimplemented createEditor() & friends in my delegate and call QTreeView:penPersistentEditor() for each row when new rows are added.

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.