Results 1 to 13 of 13

Thread: Signal when end edit Item

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Signal when end edit Item

    maybe it's not a best solution,but anyway, block signals when you create items and then you can use itemChanged or cellChanged.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  2. #2
    Join Date
    Apr 2009
    Posts
    75
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Signal when end edit Item

    Quote Originally Posted by spirit View Post
    maybe it's not a best solution,but anyway, block signals when you create items and then you can use itemChanged or cellChanged.
    ok! It's seems to work cellChanged, almost:

    how to disable cellChange when I'm creating and putting Item into TableWiew:
    Qt Code:
    1. QTableWidgetItem *newItem1 = new QTableWidgetItem(tr("%1").arg(query.value(1).toString()));
    2. tmp_table->setItem(row, col++, newItem1);
    To copy to clipboard, switch view to plain text mode 

    ?

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Signal when end edit Item

    try this
    Qt Code:
    1. const bool isBlocked = tmp_table->blockSignals(true);
    2. //add items here
    3. tmp_table->blockSignals(isBlocked);
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  4. #4
    Join Date
    Jul 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signal when end edit Item

    I haven't tested with QTableWidget, but I know that with QListWidget there's a much better solution than using QListWidget::itemChanged and trying to block all the signals when adding/changing colors/setting flags, and doing anything else that "changes" the item.

    Try this...

    Qt Code:
    1. connect(ui.pTblItems->itemDelegate(), &QAbstractItemDelegate::commitData, this, &MyWidget::OnTblItemsCommitData);
    To copy to clipboard, switch view to plain text mode 

    Then implement the slot like this...

    Qt Code:
    1. void MyWidget::OnTblItemsCommitData(QWidget* pLineEdit)
    2. {
    3. QString strNewText = reinterpret_cast<QLineEdit*>(pLineEdit)->text();
    4. int nRow = ui.pTblItems->currentRow();
    5. // do whatever you need here....
    6. }
    To copy to clipboard, switch view to plain text mode 

    Like I said... I only tried this for QListWidget, so who knows it might not work at all for the table widget, but the two classes are pretty similar so I wouldn't be surprised if it worked. You might have to tweak that code a bit to make it table widget specific.

Similar Threads

  1. How to edit Horizontal Header Item in QTableWidget
    By ioannis in forum Qt Programming
    Replies: 6
    Last Post: 5th March 2013, 18:50
  2. Help on QListWidget InternalMove item signal
    By tho97 in forum Qt Programming
    Replies: 3
    Last Post: 14th February 2009, 01:13
  3. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  4. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

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.