Results 1 to 2 of 2

Thread: Intercepting Events Emitted by QTableWidgetItem Objects

  1. #1
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Intercepting Events Emitted by QTableWidgetItem Objects

    Hi,

    I'm trying to link up and keep in sync two QTableWidget objects which contain check boxes. Both tables may have 40, 80 or 160 items. When an item in one of the tables is checked, it also checks a number of some other related items in the same table using setCheckState(Qt::Checked). This may cause further check operations to propagate until a stable state is reached. At the same time, whenever an item in the first table is checked, the corresponding item is checked in the second table creating an avalanche of change events. On top of that, the second table also bounces back events and tries to check items in the first table. I found that this is not only slow but also crashes the application probably because of the call stack overflow. I tried to implement en event filter on the QTableWidget table but it didn't work. I also tried to implement the same filter on the QTableWidget's model object but it also failed to trap check events. QTableWidgetItem class doesn't inherit from QObject or any other class so it cannot have event filters. Finally, I tried to inherit from QTableWidgetItem and re-implement setData() controlling calls to model->itemChanged(this); but new setData() will have to access private data from QTableWidgetItem. I know it sounds like a bad design, but I have no time to reimplement the code that someone has already put in place. Basically, all I want is to be able to set checkbox items in a table without triggering itemChanged events. Can someone help ,please?

    Kind Regards,
    E Gruber

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

    Default Re: Intercepting Events Emitted by QTableWidgetItem Objects

    I warmly suggest you to consider rewriting it with clean model-view approach. However, since there is no time, you could try working it around for now by temporarily blocking signals with QObject::blockSignals().
    J-P Nurmi

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

    choban (22nd August 2007)

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.