Results 1 to 9 of 9

Thread: QTableWidget signal/slot question

  1. #1
    Join Date
    Apr 2007
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableWidget signal/slot question

    Hi,

    I am relatively new to Qt and am having a problem with a signal/slot configuration. I am using Qt version 4.2.2, Windoze flavor.

    I have a dialog with a tabwidget and on one of the pages of the tabwidget I have a QTableWidget. I can enter and retrieve values from the table widget with no problem.

    I want to set up a cellClicked signal to call a slot when a cell is clicked.

    What I have is:


    -In the header file-

    public slots:

    void SlotTestEquipTableActive(int row,int col);


    - In the Cpp file-

    the connection:

    connect(this->TestEquipTableWidget,SIGNAL(cellClicked(int,int)) ,
    this, SLOT(SlotTestEquipTableActive(int,int)));

    the slot:

    void TestLogtabDlg::SlotTestEquipTableActive(int row, int col)
    {
    qDebug() << "inside test equipment slot now!"; // called?
    }

    I have a similiar set up for line edits on other pages of the tab widget and they all work fine. The QTableWidget is the only problem I have.

    The code builds and executes and there are no messages displayed in the debugView output which indicate any problems with the QTableWidget configuration, but when I click in any of the cells of the table, the slot is never called.....nothing happens at all except the cell is highlited.

    So there seems to be something different about using the QTableWidget signals than the signals emitted by the lineEdits, but I can't figure out what that is.

    On a side note....is there an easy way to determine if the problem in a signal/slot configuration lies with the signal, or the slot, or both when nothing is happening as in this case....

    Thanks in advance

    Tim

  2. #2
    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 signal/slot question

    Quote Originally Posted by twells55555 View Post
    On a side note....is there an easy way to determine if the problem in a signal/slot configuration lies with the signal, or the slot, or both when nothing is happening as in this case....
    QObject::connect() spits out a descriptive warning in case establishing the connection fails. Does TestLogtabDlg contain required Q_OBJECT macro?
    J-P Nurmi

  3. #3
    Join Date
    Apr 2007
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget signal/slot question

    Hi JPN, thanks for your reply

    I monitor the error output with debugView when I execute the app and have seen the QObject::connect error messages you mention other times when I screwed something up. But in this case, I get no debugView warning/error messages at all....and the code builds and runs cleanly as well. I can find no indication that anything is going wrong except that the slot which is supposed to be called when I click in a cell never executes....and all I'm trying to do in the slot right now is generate a QDebug() message saying it was entered...
    nothing complicated.

    Yes, I have doublechecked to make sure the Q_OBJECT macro is there and it is, and other signal/slot configurations I use with lineEdits are working fine.


    tim

  4. #4
    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 signal/slot question

    Have you reimplemented any event handlers or installed an event filter?
    J-P Nurmi

  5. #5
    Join Date
    Apr 2007
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget signal/slot question

    JPN,

    I added another dialog with a table widget in my app as a test and was able to connect the signal/slots and it worked as expected. Weird. So I deleted the table giving me the problem on the tab widget page, recreated it, and rebuilt and it also works fine now.

    I'm not sure if I inadvertantly blocked sending signals from the original table when I was experimenting with its design in designer or what but it is working now. Thanks for your help.

    The only remaining problem I have with the table is trying to make it a fixed size, fixed width, no scrolling, and no shadowing. In short, just a plain fixed size x by x table on a form. Seems like that should be easy enough to do...maybe even the default... but that doesn't seem to be the case. (Which is what got me messing with the table settings in the first place...).

    Anyway, Thanks again for your help, I realy appreciate it.

    tim

  6. #6
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget signal/slot question

    twells55555, for fixed size simply set the minsize and maxsize attributes to the same value..

  7. #7
    Join Date
    Apr 2007
    Location
    Toruń, POLAND
    Posts
    24
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTableWidget signal/slot question

    twells55555, where do you click and what kind of editors (in table) do you have?

  8. #8
    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 signal/slot question

    Quote Originally Posted by twells55555 View Post
    The only remaining problem I have with the table is trying to make it a fixed size, fixed width, no scrolling, and no shadowing. In short, just a plain fixed size x by x table on a form.
    I'm not exactly sure how do you want it to behave but here are a few hopefully helpful references:
    J-P Nurmi

  9. #9
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget signal/slot question

    The last time i was looking for setFixedSize() in the gui editor it wasn't available. Maybe the trolls have changed it in a newer version..

Similar Threads

  1. QTableWidget question
    By larry104 in forum Qt Programming
    Replies: 2
    Last Post: 20th October 2006, 21:46
  2. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46

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.