[Gllug] QT advise

Matthew Joseph Smith indigojo_uk at yahoo.co.uk
Mon Feb 19 10:22:06 UTC 2007


Wenceslao Requejo wrote:
> Hi everyone;
> 
> On the main_window.h and .cpp is a bit different, as it has many
> signals. So here it comes my question. 
> What is the best approach then to implement and use a object of the clas
> main_windo.h (i.e. A main window)?
> 	a) Write the code needed on the signals or callbacks on main_window.cpp
> and "hope" that somehow the compiler will not overwrite this changes
> within the signal functions. OR
> 	b) Create a new sub class of main_window.h and "redefine" the slots or
> callbacks as needed.
> Please asume that the slots or callbacks will need to do a bit more than
> closing the window. i.e. objects, dialogs and other functions from other
> classes should be called from them.

Hi there,

With Qt 3, you don't always need to subclass.  You can double-click 
anywhere on the form's background and it will display a code-editing 
widget where you can simply type any new slots you might want to add to 
the widget.  You can save this file as widgetname.ui.h (or Designer will 
do it for you - it's a while since I've done any Qt 3 programming) and 
it will be #included at the time of compilation.

(However, if you're thinking of migrating to Qt 4, this no longer works. 
  You need to read the Qt 4 Designer documentation for that, because the 
ui.h system has gone and the way of subclassing has totally changed in 
Qt 4.)

Qt certainly will not rename any objects or slots.  What you can't do is 
edit the files produced by Qt Designer and expect your changes still to 
be there when you next open them in Qt Designer.  It will simply read 
the .ui file and the new code will be generated according to it, erasing 
your changes.  So you either have to subclass it or use the ui.h method 
I just described.

And we don't talk about callbacks in Qt.  Qt does not use them.

I hope this helps.

Matt Smith
-- 

http://www.blogistan.co.uk/qt/
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list