Results 1 to 6 of 6

Thread: How to put a checkbox or a widget into a QTableWidget header?

  1. #1
    Join Date
    Jul 2013
    Posts
    9
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default How to put a checkbox or a widget into a QTableWidget header?

    Hi guys, my objective is to put a checkbox in the header. To be more clear and easy to the User do the "SelectionAll" function

    So I have this Widget, and I need to put a checkbox (or a widget with a checkbox) inside the red circle on the image.

    QTableView.png

    Thanxs.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to put a checkbox or a widget into a QTableWidget header?

    The corner button does "select all" and is enabled by default: QTableView::setCornerButtonEnabled().

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

    Dangelo (16th August 2013)

  4. #3
    Join Date
    Jul 2013
    Posts
    9
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to put a checkbox or a widget into a QTableWidget header?

    Quote Originally Posted by ChrisW67 View Post
    The corner button does "select all" and is enabled by default: QTableView::setCornerButtonEnabled().
    But I need to put a checkbox there to the User...I found that using the QTableView::setCornerWidget would solve my problem, but I don't know why, when I set the widget with the checkbox (like in the other lines of the table), nothing changes, the corner still remain blank
    Last edited by Dangelo; 16th August 2013 at 20:38.

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to put a checkbox or a widget into a QTableWidget header?

    The QAbstractScrollArea::setCornerWidget() call puts a widget in the corner between the scroll bars ( bottom right) and this is only visible if one or both scroll bars are. AFAICT there is no way to substitute your own widget for the select all button in the top left. The button already has the function of selecting everything and the items are highlighted when selected so there is feed back to the user. I don't see what adding a checkbox to control the same function will get you.

  6. The following user says thank you to ChrisW67 for this useful post:

    Dangelo (16th August 2013)

  7. #5
    Join Date
    Jul 2013
    Posts
    9
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to put a checkbox or a widget into a QTableWidget header?

    Quote Originally Posted by ChrisW67 View Post
    The QAbstractScrollArea::setCornerWidget() call puts a widget in the corner between the scroll bars ( bottom right) and this is only visible if one or both scroll bars are. AFAICT there is no way to substitute your own widget for the select all button in the top left. The button already has the function of selecting everything and the items are highlighted when selected so there is feed back to the user. I don't see what adding a checkbox to control the same function will get you.
    Now I saw what ConerWidget() does...>.
    My objective is (or was..) a look matter, several common programs here have a checkbox in the top left where the user can interact to do the selectAll function. So it's nice to present in a way which the user is familiar with, that makes the software be more intuitive.
    Anyway thanxs for the support (:!

  8. #6
    Join Date
    Jul 2013
    Posts
    9
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to put a checkbox or a widget into a QTableWidget header?

    Hi, I found a solution to the problem, if anyone else is interested
    checkedheader.cpp.h

  9. The following user says thank you to Dangelo for this useful post:

    ymyasoedov (20th November 2013)

Similar Threads

  1. Replies: 0
    Last Post: 12th January 2012, 06:41
  2. checkbox implementation in QTableWidget display issue
    By prajesh in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2010, 09:35
  3. Accessing check state of CheckBox in QTableWidget
    By lnxusr in forum Qt Programming
    Replies: 6
    Last Post: 22nd November 2009, 01:13
  4. Replies: 2
    Last Post: 5th June 2008, 21:32
  5. How to delete header on QTableWidget
    By jlbrd in forum Qt Programming
    Replies: 2
    Last Post: 18th July 2006, 21:00

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.