Results 1 to 5 of 5

Thread: QTableWidget signals

  1. #1
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QTableWidget signals

    Hi all;


    I am using a QTableWidget with combobox item and spinboxItem. What signal should I use to know if one item has his value changed.


    thanks
    power of mind > mind of power

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget signals

    http://doc.trolltech.com/4.2/qtablew...ml#itemChanged

    just wondering... Is browsing the doc sooooooooo tedious???
    Current Qt projects : QCodeEdit, RotiDeCode

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

    Default Re: QTableWidget signals

    Just as a side node, the table widget does not emit any signals in case those are cell widgets. The cell widgets itself emit their own signals when their values change.

    Btw, is it an ordinary spinbox with plain numerical data? Another (and much more light-weight) option would be to set the data to the table widget items as numbers, not as text. Then the delegate would provide a spinbox as an editor, out of the box.

    Qt Code:
    1. int number = 123;
    2. item->setData(Qt::DisplayRole, number);
    3. // i don't remember if table widget items are editable by default,
    4. // the following line will make sure they are
    5. item->setFlags(item->flags() | Qt::ItemIsEditable);
    6. tableWidget->setItem(row, col, item);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. #4
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget signals

    thanks for help but it is not working.

    I want make the saveBotton not disabled when I make a change in the QTableWidget.
    Qt Code:
    1. void MyClass::on_tableWidget_itemChanged(QTableWidgetItem*)
    2. {
    3. ui.SaveBotton->setDisabled(false);
    4. }
    To copy to clipboard, switch view to plain text mode 
    power of mind > mind of power

  5. #5
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget signals

    Do you have access to the widgets when they are created? If so just connect proper signals...

    Otherwise you should :
    1. add a QPointer<QWidget*>member
    2. on QTableWidget::cellActivated(), if non-zero, disconnect its proper signal (change of value) from your enable/disable slot
    3. set it to QTableWidget::cellWidget() and connect its proper signal to your enable/disable slot
    Qt Code:
    1. // assuming the class as a member like : QPointer<QWidget*> m_cellwidget
    2.  
    3. void MyClass::on_tableWidget_cellActivated(int row, int column)
    4. {
    5. if ( m_cellwidget )
    6. {
    7. disconnect(m_cellwidget, SIGNAL( ),
    8. this , SLOT ( ) );
    9.  
    10. }
    11.  
    12. m_cellwidget = cellWidget(row, column);
    13.  
    14. if ( m_cellwidget )
    15. {
    16. connect(m_cellwidget, SIGNAL( ),
    17. this , SLOT ( ) );
    18.  
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 

    P.S. : Don't forget to fill in the blanks... Also as you mentionned that your widgets are of two types you should check for this and choose the appropriate signal...

    Hope this helps.
    Last edited by fullmetalcoder; 1st April 2007 at 14:10. Reason: reformatted to look better
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. QTableWidget (resizing rows, turning off selection, etc.)
    By kiss-o-matic in forum Qt Programming
    Replies: 6
    Last Post: 11th January 2007, 01:57
  2. print QTableWidget
    By chak_med in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2006, 18:46
  3. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46
  4. Replies: 6
    Last Post: 5th March 2006, 21:05
  5. KDE Signals
    By chombium in forum KDE Forum
    Replies: 1
    Last Post: 25th January 2006, 18: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.