Results 1 to 13 of 13

Thread: Deselect lines in table views

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: [resolved] Deselect lines in table views

    Use signal and slots. Try something like that:
    Qt Code:
    1. w1.setRowCount(5);
    2. w1.setColumnCount(3);
    3.  
    4. w2.setRowCount(5);
    5. w2.setColumnCount(3);
    6.  
    7. for(int row = 0; row < 5; ++row)
    8. {
    9. for(int column = 0; column < 3; ++column)
    10. {
    11. QTableWidgetItem *newItem = new QTableWidgetItem(QString("%1").arg((row+1)*(column+1)));
    12. w1.setItem(row, column, newItem);
    13. }
    14. }
    15.  
    16. for(int row = 0; row < 5; ++row)
    17. {
    18. for(int column = 0; column < 3; ++column)
    19. {
    20. QTableWidgetItem *newItem = new QTableWidgetItem(QString("%1").arg((row+1)*(column+1)));
    21. w2.setItem(row, column, newItem);
    22. }
    23. }
    24.  
    25. l.addWidget(&w1);
    26. l.addWidget(&w2);
    27. w.setLayout(&l);
    28. w.show();
    29.  
    30. QObject::connect(&w1, SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)), &w2, SLOT(clearSelection()));
    To copy to clipboard, switch view to plain text mode 
    But be aware that this is just a demonstration. You have to make a own slot, from where you clear the table widgets and make sure that you don't get a infinite loop. To know which table widget calls the slot use QTableWidgetItem::tableWidget().

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

    kremuwa (15th August 2010)

Similar Threads

  1. How to add new lines in a table view
    By klaus1111 in forum Newbie
    Replies: 1
    Last Post: 17th August 2006, 11:45

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.