Results 1 to 4 of 4

Thread: QTableWidget QTableWidgetItem

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QTableWidget QTableWidgetItem

    Hello all,
    sorry, I couldn't find exactly what I was looking for prevoius threads.
    I want to change the color of a header of a column in a QTableWidget (to show that the column is 'active'). The column header is double clicked and I get a slot called in which I do this:
    Qt Code:
    1. item = tableWidget->horizontalHeaderItem ( logicalIndex );
    2. item->setBackgroundColor(ChannelEnabled);
    To copy to clipboard, switch view to plain text mode 

    There is no colour change to be seen. I can colour any other item in the table this way, but not those from the headers. What do I need to do?

    Another thing...
    the signal QTableWidget::itemDoubleClicked ( QTableWidgetItem * /*item*/ )
    gets called on double click on any cell, except those in the headers.

    thanks
    Kev
    Last edited by TheKedge; 6th September 2006 at 14:41. Reason: updated contents

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableWidget QTableWidgetItem

    Quote Originally Posted by TheKedge
    There is no colour change to be seen. I can colour any other item in the table this way, but not those from the headers. What do I need to do?
    You must either override
    QHeaderView::paintSection()or
    use a custom style and implement:
    QStyle::drawControl(QStyle::CE_Header)
    Another thing...
    the signal QTableWidget::itemDoubleClicked ( QTableWidgetItem * /*item*/ )
    gets called on double click on any cell, except those in the headers.
    QHeaderView::sectionDoubleClicked()

    PS. Headers are accessible through QTableView::horizontalHeader() and QTableView::verticalHeader()
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    TheKedge (6th September 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QTableWidget QTableWidgetItem

    Yep,
    QHeaderView::sectionDoubleClicked()
    PS. Headers are accessible through QTableView::horizontalHeader() and QTableView::verticalHeader()
    that're what I'm using at the moment.

    I was a little irked that I could get the item, but that the QTableWidgetItem func didn't work.

    I'll try your suggestions, thanks very much.

    K

  5. #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 QTableWidgetItem

    Quote Originally Posted by TheKedge
    I was a little irked that I could get the item, but that the QTableWidgetItem func didn't work.
    Headers are not items. They are not part of the data model data.

Similar Threads

  1. QTableWidget Update - slow
    By DPinLV in forum Qt Programming
    Replies: 16
    Last Post: 18th August 2006, 21:09
  2. Problem inserting in QTableWidget
    By DPinLV in forum Qt Programming
    Replies: 2
    Last Post: 2nd August 2006, 00:10
  3. QTableView versus QTableWidget
    By jcr in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2006, 19:51
  4. Replies: 6
    Last Post: 5th March 2006, 21:05
  5. QTableWidget -> QDockWidget,
    By ogre in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2006, 06: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.