Results 1 to 13 of 13

Thread: How to handle QTableView's behaviour

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: How to handle QTableView's behaviour

    In paint() try:
    Qt Code:
    1. QColor color = index.data().value<QColor>();
    To copy to clipboard, switch view to plain text mode 

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

    alitoh (13th May 2011)

  3. #2
    Join Date
    Mar 2011
    Posts
    82
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to handle QTableView's behaviour

    Quote Originally Posted by norobro View Post
    In paint() try:
    Qt Code:
    1. QColor color = index.data().value<QColor>();
    To copy to clipboard, switch view to plain text mode 
    Great. Thanks a lot.

    Now the updating works, but the name is kinda messed up, for it shows it's hex value instead of the proper noun. Still, this is quite an improvement.
    Care to explain a little more what's going on in that line, because I'm barely keeping up with delegates, to be honest.

  4. #3
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: How to handle QTableView's behaviour

    Quote Originally Posted by alitoh View Post
    . . . I'm barely keeping up with delegates, to be honest.
    Looks to me like you are handling delegates pretty well

    Take a look at QVariant::value() in the docs. As long as the color name in your cell is recognized by Qt that statement will work. To see the list of Qt recognized color names use:
    Qt Code:
    1. qDebug() << QColor::colorNames();
    To copy to clipboard, switch view to plain text mode 
    My Debian system lists 148 colors.

    Regarding the text, use:
    Qt Code:
    1. painter->drawText(option.rect.x() + 27, option.rect.y() + 20, index.data().toString());
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. [QTableView] Custom selection behaviour
    By Rid in forum Qt Programming
    Replies: 3
    Last Post: 27th April 2012, 07:17
  2. QLineEdit behaviour
    By zgulser in forum Qt Programming
    Replies: 0
    Last Post: 9th July 2010, 14:37
  3. Handle KeyRelease or KeyPress on any row in QTableView
    By AbuYusuf in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2010, 20:04
  4. Different behaviour of QApplication!!
    By Raajesh in forum Qt Programming
    Replies: 2
    Last Post: 30th June 2008, 17:00
  5. [Qt 4.1] Strange behaviour with QTableView
    By fane in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2006, 06:17

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.