Results 1 to 18 of 18

Thread: QTableWidget Problem, setRowWidget? :P

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget Problem, setRowWidget? :P

    Yes, I understand your problem :

    - You click on a column header to sort data, and you also want the other columns to be adjusted, in order to keep your rows the same !

    - If you really want to keep QTableWidget, I think you should :

    1) deactivate the default sorting method with setSortingEnabled(false)
    2) connect a custom sorting slot to the header signal sectionClicked()
    3) implement your custom sorting function to sort just like you want

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

    VireX (6th April 2007)

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

    Default Re: QTableWidget Problem, setRowWidget? :P

    Thanks for the help guys. However, I tried a small test with random text in the cells, and it turns out wysota is right, it is automatically locked... I am so shocked, I tested it before and I coulda sworn it wasn't like that! I cannot believe it... But I definitely belong to this forum for another month now .

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

    Default Re: QTableWidget Problem, setRowWidget? :P

    Qt Code:
    1. for(int i = 1; i < 53; i++){
    2. t_Items << new QTableWidgetItem(QString("%1").arg(i));
    3. p_Items << new QTableWidgetItem(QString("55 - %1").arg(i));
    4. s_Items << new QTableWidgetItem(QString("milliseconds: %1 ms").arg(i));
    5. i_Items << new QTableWidgetItem(QString("Description %1").arg(i));
    6. TableW->setItem(i-1, 0, t_Items[i-1]);
    7. TableW->setItem(i-1, 1, p_Items[i-1]);
    8. TableW->setItem(i-1, 3, s_Items[i-1]);
    9. TableW->setItem(i-1, 4, i_Items[i-1]);
    10. }
    To copy to clipboard, switch view to plain text mode 
    So I am trying to use a loop, I am adding some information onto the QTableWidget.
    There are already 55 rows available, and I'm adding them onto the table, but for some reason, the program usually crashes.

    all the t_Items and other Items are QList<QTableWidgetItem *>

  5. #4
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget Problem, setRowWidget? :P

    You should post a larger sample of code, a compilable one would be the best.

    Also, post the debug backtrace of your crash !

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

    Default Re: QTableWidget Problem, setRowWidget? :P

    I cannot debug. When I debug, there is no problem except that
    setItem for column 2-4-5 don't work except for the VERY LAST row (52)

    My logs say, that it stops recording in the game loop (counts to 52 and program crashes) when NOT DEBUGGING;;;; when debugging... absolutely no problems.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget Problem, setRowWidget? :P

    Quote Originally Posted by VireX View Post
    There are already 55 rows available, and I'm adding them onto the table, but for some reason, the program usually crashes.
    Maybe there isn't enough columns?

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

    Default Re: QTableWidget Problem, setRowWidget? :P

    You know what nvm, you guys don't see anything wrong with it.

    Also, the fact that me commenting out CreateList(), still causes a crash (but this time moves to end of the program), but when theres CreateList() (with almost no code except a log function, which proves its something related to my program and not Qt Table).

    Ok one last question
    Let's say I have 2 pushbuttons:
    label: Add
    Labal: Del

    If I were to setCellWidget the pushbutton to one column, but if I were to click the header "to sort", would it sort all the Add buttons at top and Del buttons at bottom (or vice-versa)? or would it not know how to sort PushButtons?

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

    Default Re: QTableWidget Problem, setRowWidget? :P

    Is there any sample sorting code, to sort some widgets or something?
    Last edited by VireX; 6th April 2007 at 18:20.

Similar Threads

  1. QTableWidget issues
    By Djony in forum Qt Programming
    Replies: 42
    Last Post: 19th December 2006, 23:27
  2. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46
  3. Problem inserting in QTableWidget
    By DPinLV in forum Qt Programming
    Replies: 2
    Last Post: 2nd August 2006, 00:10
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Replies: 6
    Last Post: 5th March 2006, 21: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.