Results 1 to 9 of 9

Thread: Column Colour

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Column Colour

    Did you correct that paint() call?

    You have:
    Qt Code:
    1. QTableItem::paint (p, cg, cr, selected);
    To copy to clipboard, switch view to plain text mode 
    and it should be:
    Qt Code:
    1. QTableItem::paint (p, g, cr, selected);
    To copy to clipboard, switch view to plain text mode 

    This works for me:

    Qt Code:
    1. #include <qapplication.h>
    2. #include <qtable.h>
    3.  
    4. class MyTableItem : public QTableItem {
    5. public:
    6. MyTableItem(QTable *table) : QTableItem(table, QTableItem::OnTyping){}
    7. void paint(QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected){
    8. QColorGroup g(cg);
    9. g.setColor(QColorGroup::Base, Qt::red);
    10. QTableItem::paint(p, g, cr, selected);
    11. }
    12.  
    13. };
    14.  
    15. int main(int argc, char **argv){
    16. QApplication app(argc, argv);
    17. QTable tab(1,1);
    18. tab.setItem(0,0, new MyTableItem(&tab));
    19. app.setMainWidget(&tab);
    20. tab.show();
    21. return app.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to wysota for this useful post:

    sumsin (15th June 2006)

Similar Threads

  1. Setting Delegates per Column
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2006, 21:39
  2. QTable column stretchable with minimum Width
    By sunil.thaha in forum Qt Programming
    Replies: 0
    Last Post: 24th April 2006, 13:17
  3. background colour
    By kw in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2006, 00:44
  4. hidden QListView column suddenly visible
    By edb in forum Qt Programming
    Replies: 10
    Last Post: 27th January 2006, 08:00
  5. How to dispay an icon in the first column of QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 1
    Last Post: 5th January 2006, 15:51

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
  •  
Qt is a trademark of The Qt Company.