PDA

View Full Version : QTableWidget signal/slot question



twells55555
24th July 2007, 16:43
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

jpn
25th July 2007, 06:37
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 (http://doc.trolltech.com/4.3/qobject.html#Q_OBJECT) macro?

twells55555
25th July 2007, 14:15
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

jpn
25th July 2007, 14:49
Have you reimplemented any event handlers or installed an event filter?

twells55555
29th July 2007, 14:19
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

aMan
30th July 2007, 07:38
twells55555, for fixed size simply set the minsize and maxsize attributes to the same value..

macias
30th July 2007, 12:13
twells55555, where do you click and what kind of editors (in table) do you have?

jpn
6th August 2007, 21:08
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:

QWidget::setFixedSize()
QAbstractScrollArea::setHorizontalScrollBarPolicy( )
QTableView::horizontalHeader()
QHeaderView::setResizeMode()

aMan
6th August 2007, 21:58
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..