Results 1 to 5 of 5

Thread: QTableWidget Sorting Widgets!

  1. #1
    Join Date
    Jan 2007
    Posts
    209
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default QTableWidget Sorting Widgets!

    IS there any way for me to sort buttons?
    Say I have a button called EditBox, DeleteBox, I want to put all rows with EditBox cellWidgets on the top, and all DeleteBox should be below, and it also should sort by number as well.

    so an example would be:
    45 Edit
    46 Edit
    47 Edit
    48 Edit
    1 Delete
    2 Delete
    3 Delete
    4 Delete
    5 Delete

    How would I code a sorting scheme for that? I believe I would connect headerView() to sectionClicked, and maybe write a function for it, but I have no idea how I would write the function.

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

    Default Re: QTableWidget Sorting Widgets!

    J-P Nurmi

  3. #3
    Join Date
    Jan 2007
    Posts
    209
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Re: QTableWidget Sorting Widgets!

    That's not going to help because a cell Widget is not a TableWidgetItem... so reimplementing that won't help.

    I believe I do have to edit the headerView.

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

    Default Re: QTableWidget Sorting Widgets!

    Quote Originally Posted by VireX View Post
    That's not going to help because a cell Widget is not a TableWidgetItem... so reimplementing that won't help.
    Create items underneath cell widgets. You can even get away with plain QTableWidgetItem if the content is plain textual or numerical data and set on both, on the button and on the item. In case you need smarter sorting, you need to reimplement the aforementioned operator.
    Attached Files Attached Files
    J-P Nurmi

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

    VireX (14th April 2007)

  6. #5
    Join Date
    Jan 2007
    Posts
    209
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Re: QTableWidget Sorting Widgets!

    Wow, thank you, I didn't know you can setItem ANNNNDD setCellWidget too.

Similar Threads

  1. QLogText & QLogTable : 2 widgets to display text log
    By fcoiffie in forum Qt-based Software
    Replies: 7
    Last Post: 28th April 2019, 08:52
  2. Sorting elements in QTableWidget
    By Elmo23x in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 09:35
  3. Model sorting vs. selection
    By VlJE in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 17:46
  4. QTableWidget Sorting
    By mclark in forum Newbie
    Replies: 4
    Last Post: 29th September 2006, 23:34
  5. QTableWidget Sorting Multiple Selection
    By rhiacasta in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2006, 22:05

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.