Results 1 to 2 of 2

Thread: how to set check box on QTableWidget's header

  1. #1
    Join Date
    Mar 2017
    Posts
    2
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default how to set check box on QTableWidget's header

    Hi All ,


    I'm trying to implement a table widget which has checkable items in it.


    And I want to place a check box on the horizontal header to let user "Check
    All" and "Uncheck All" by checking or unchecking this check box.

    Does anybody know how to do this?

    I tried the following:

    QTableWidgetItem* item = new QTableWidgetItem("Check");
    item->setCheckState(Qt::Checked);
    table->setHorizontalHeaderItem(0, item);

    But the header does not have a check box on it.



    Thanks in advance

  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: how to set check box on QTableWidget's header

    You need to subclass QHeaderView, paint the checkboxes within paintSection(), handle mouse events and replace the original header with your custom one in the view itself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. add comobox as the header of QTableWidget
    By xiongxiongchuan in forum Qt Programming
    Replies: 0
    Last Post: 15th June 2010, 11:14
  2. Accessing check state of CheckBox in QTableWidget
    By lnxusr in forum Qt Programming
    Replies: 6
    Last Post: 22nd November 2009, 01:13
  3. Replies: 1
    Last Post: 23rd March 2009, 21:36
  4. Replies: 0
    Last Post: 2nd May 2008, 07:57
  5. Tooltip on QTableWidget header
    By ghorwin in forum Qt Programming
    Replies: 4
    Last Post: 29th October 2007, 09:34

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.