PDA

View Full Version : signal slot confusion



mstegehu
28th August 2009, 14:59
When reading the manual about auto-connect signal/slots I was getting confused a little.

I create a form with the designer and create some signals and slots.

Uic gives me a ui_XXX.h

I use that in my NewWidget.

Do or do I not have to MOC my NewWidget.h.

And is there anyone with an example of 3-th party slots usage?

Regards,

Marcel

jpn
28th August 2009, 15:07
Aren't you using qmake? It takes care of uic and moc, automatically.

mstegehu
31st August 2009, 08:10
Hello,

No I am justing using VCPROJ files. Due to our own Object + Signal Slots we want to avoid moc-ing an object that inherits our own Object.

Regards,

Marcel

wysota
31st August 2009, 10:22
Do or do I not have to MOC my NewWidget.h.

It depends what you have there. If you declare new signals or slots in NewWidget then you should run moc on it.

jpn
31st August 2009, 10:56
Let qmake generate the .vcproj for you (and re-generate it whenever you add/remove a Q_OBJECT macro) and you're fine. By the way, just in case.. it's "qmake -tp vc".

mstegehu
31st August 2009, 11:27
wysota,

So, the designer UI file with auto connect signals and slot generates a .h file that does not need to be moc-ed anymore.

I thought one needed Meta information of the object and signals slots to connect them. So how is that done when the uic generated .h file has no Q_OBJECT macro. Or is that what the call to QMetaObject::connectSlotsByName(BaseObject) is for combined with the setting of the ObjectNames?

Regards,

Marcel

wysota
31st August 2009, 11:41
I thought one needed Meta information of the object and signals slots to connect them.
Only if you declare the signals or the slots in this particular class. But files generated from UI files are not widgets, so they can't be moced. You need to provide your own subclass of QWidget that needs mocing.


So how is that done when the uic generated .h file has no Q_OBJECT macro.
Because it's not a QObject.