[Qt-interest] Creating a new slot with qtcreator

Arnold Krille arnold at arnoldarts.de
Sat Jun 20 09:58:46 CEST 2009


Hi,

On Friday 19 June 2009 01:57:07 Svenn Are Bjerkem wrote:
> I'm following "The independent Qt Tutorial" address book example on
> http://www.digitalfanatics.org/projects/qt_tutorial/chapter07.html and
> obviously this tutorial is using Qt Designer and an older version of
> Qt, but I wanted to take the challenge to re-perform it in qtcreator.
> Now I am a bit stuck on the part where the addContact() slot is
> supposed to be created. From a search on google it looks as if there
> is no way of defining a new slot the way Qt Designer does it in this
> tutorial.

The way ui-files (these things created in the designer) work has changed quite 
a bit from qt3 to qt4.
With qt3 you had to subclass from the class created in the designer. And 
therefor the designer allowed the direct creation of code (signals and slots).
With Qt4 the designer creates a class, but that is _really_ lightweight. And 
you don't subclass from it alone, but at least also from the real base-class 
of your widget/window. And all the manual code adding is completely gone from 
designer in qt4.

To execute code upon certain signals without manually connecting the 
signals/slots, use the automatic connection mechanism, that is in your derived 
class define a slot on_ObjectName_signalName() where you do the stuff.

I am probably not that good at explaining it, but the Qt documentation is. I 
suggest you start by reading it. It also has some good examples and 
tutorials...

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090620/cfd86e14/attachment.bin 


More information about the Qt-interest-old mailing list