Results 1 to 7 of 7

Thread: QTableWidget customize row colour

  1. #1
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QTableWidget customize row colour

    Hi everyone
    I've encountered a problem while using sheets with Qt Designer. I try to set color for a row as a gradient like this
    Qt Code:
    1. {
    2. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
    3. stop: 0 #ffffff, stop: 1 #ecf9ff);
    4. }
    To copy to clipboard, switch view to plain text mode 
    But instead of painting a row with this gradient it paints all rows from top to bottom with it like it is a solid piece
    C++ & AMD forever

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: QTableWidget customize row colour

    Well... if you ask the stylesheet to paint all widgets inheriting QTableWidget in such a way, it does exactly so. You didn't mention you wanted items or so... and besides, you can't style items in Qt 4.3 and older.

  3. #3
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTableWidget customize row colour

    So it is impossible to fill each row of table widget with gradient ?
    C++ & AMD forever

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: QTableWidget customize row colour

    I didn't say that. Your stylesheet is incorrect. If you want to do it with stylesheets, you'll need Qt 4.4. If you want to do it without stylesheets - provide a custom delegate and do the painting there.

  5. #5
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTableWidget customize row colour

    It's funny that it is possible to customze aternate row colour with gradient while it isn't possible to do it for ordinary row.

    I think I wont be able to use delegates for this because I don't know how to implement them
    C++ & AMD forever

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: QTableWidget customize row colour

    Quote Originally Posted by THRESHE View Post
    I think I wont be able to use delegates for this because I don't know how to implement them
    It's really easy, try it. Subclass QItemDelegate and reimplement paint(). Fill the rectangle specified with your gradient and then call the base class implementation of drawDisplay(). You'll have something to start with...

  7. #7
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTableWidget customize row colour

    Quote Originally Posted by wysota View Post
    It's really easy, try it. Subclass QItemDelegate and reimplement paint(). Fill the rectangle specified with your gradient and then call the base class implementation of drawDisplay(). You'll have something to start with...
    Thanks I'll try it
    C++ & AMD forever

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.