PDA

View Full Version : QTabWidget problem



alan lenton
6th July 2008, 12:32
Hi,

I'm having a problem with QTabWidget
O/s is Windows, Development environment VS2005, QT version 4.3.4

I have a QTabWidget called MainNotebook and I'm trying to connect its currentChanged(int index) signal to my private slot void on_PageChange(int new_page);

This is the connect macro:
connect(ui.MainNotebook,SIGNAL(currentChanged()),t his,SLOT(on_PageChange()));

This is the signature of my slot:
void on_PageChange(int new_page);

The problem is simple - my slot doesn't seem to ever be called (I put a break point on it to check this was the case). On the other hand, all the other signal/slot connections work OK.

I'm sure I'm making a really simple mistake here, but I just can't see what!

Can anyone help, please?

alan

jpn
6th July 2008, 12:56
Does the class declaration contain the required Q_OBJECT macro? Is on_PageChange() declared as slot? QObject::connect() outputs a warning in case establishing the signal slot connection fails, see debug output for more details.

alan lenton
6th July 2008, 14:03
Does the class declaration contain the required Q_OBJECT macro?
Yes

Is on_PageChange() declared as slot?
Yes - it's declared as a private slot

QObject::connect() outputs a warning in case establishing the signal slot connection fails, see debug output for more details.
OK - I just found this amongst all the crud that VS2005 outputs when it's running!

QMetaObject::connectSlotsByName: No matching signal for on_PageChange(int)

and then a bit later:

Object::connect: No such signal QTabWidget::currentChanged()
Object::connect: (sender name: 'MainNotebook')
Object::connect: (receiver name: 'EvEditClass')

I'm still no sure what I'm doing wrong, though - this is the Qt Assistant entry for the signal:

void QTabWidget::currentChanged ( int index ) [signal]
This signal is emitted whenever the current page index changes. The parameter is the new current page index position.


Thanks for your help, anything further would be appreciated, since I still can't see the problem...

alan

_

jpn
6th July 2008, 14:06
Object::connect: No such signal QTabWidget::currentChanged()
Object::connect: (sender name: 'MainNotebook')
Object::connect: (receiver name: 'EvEditClass')

Ahh, indeed. It should be:


connect(ui.MainNotebook,SIGNAL(currentChanged(int) ),this,SLOT(on_PageChange(int)));

alan lenton
6th July 2008, 15:12
thank you!

alan

sunny127
25th July 2016, 17:16
Thank you very much!! :)