Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, August 2007
Slot QT Designer 4.3 question


Message 1 in thread

Hi

I have just moved to QT 4.3 and it is one rely simple think I just
cant figure out. Now in 3.x there where the Add slot function, where
new slots where created and then it as extremely easy to create a
signal -> slot connection.

Now I just cant figure out how I can create slots in QT Designer 4.3,
is there a way or do I have to do it manual in the class that inherit
my "qt-designer-class". Say for an example I want to connect a button,
pb_HelloWorld with the function helloWorld, how do I do this in QT
Designer 4.3. Or even worse, I have a menu item, mi_HelloWorld and I
want to connect it to a function foo.

As I said a really simple question but I can find any information on
how to create and manage you own slots either in the
manual/tutorial/examples.

best regards
Anders

--
 [ signature omitted ] 

Message 2 in thread

Hi,

this is not the way designer works in Qt4 anymore. While in Qt3 the 
designer had some kind of IDE and Project management features icluded 
those features where stripped in Qt4 designer. 
Now it is "only" a very powerful tool do design your forms - no more - no 
less! It's doing it's job great!!! Everything besides designing the GUI is 
up to the probrammer - and be honest - writing a connect() statement is 
not that much work - is it?

When doing my first steps with Qt4 I thought it would be so much more work 
now - but time showed me, that Qt-programs are way better readable now. I 
really like the new designer. Use it for a while and you will too ;-)

There is a great introduction in the Qt4-designer shipped with Qt4 and 
online at http://doc.trolltech.com/4.3/designer-manual.html .

Hope that helps a bit,

Regards,
Malte



"Anders Sandholm" <anders.sandholm@xxxxxxxxx> schrieb am 03.08.2007 
10:15:51:

> Hi
> 
> I have just moved to QT 4.3 and it is one rely simple think I just
> cant figure out. Now in 3.x there where the Add slot function, where
> new slots where created and then it as extremely easy to create a
> signal -> slot connection.
> 
> Now I just cant figure out how I can create slots in QT Designer 4.3,
> is there a way or do I have to do it manual in the class that inherit
> my "qt-designer-class". Say for an example I want to connect a button,
> pb_HelloWorld with the function helloWorld, how do I do this in QT
> Designer 4.3. Or even worse, I have a menu item, mi_HelloWorld and I
> want to connect it to a function foo.
> 
> As I said a really simple question but I can find any information on
> how to create and manage you own slots either in the
> manual/tutorial/examples.
> 
> best regards
> Anders
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx 
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 

--
 [ signature omitted ] 

Message 3 in thread

On Friday 03 August 2007 10:26:17 Malte Witt wrote:
> When doing my first steps with Qt4 I thought it would be so much more work
> now - but time showed me, that Qt-programs are way better readable now. I
> really like the new designer. Use it for a while and you will too ;-)

Hello,

You sound like somebody who tries to convince yourself that it is 'not 
necessary' to have the 'extra slots' mechanism from Qt3. I believe that Qt4 
has improved greatly but this is one of the features that I miss greatly.

Would it not be possible to have 'extra slots' in a widget and assume that 
these will be provided in the containing widget. So if I would connect a form 
button to one of these extra slots, the compiler would connect that button to 
the named slot in the container (that contains that form). At the moment a 
similar mechanism exists with the on_<widget>_<signal> list. I think that 
could be extended as to provide the possibilities of the Qt3 designer.

Of course, this kind of 6 line solutions are easy to write down. Probably 
there are very good reasons why the proposed solution would not work,

With kind regards,

Werner,-

-- 
 [ signature omitted ] 

Message 4 in thread

On 03.08.07 10:37:53, Werner Van Belle wrote:
> On Friday 03 August 2007 10:26:17 Malte Witt wrote:
> > When doing my first steps with Qt4 I thought it would be so much more work
> > now - but time showed me, that Qt-programs are way better readable now. I
> > really like the new designer. Use it for a while and you will too ;-)
> 
> You sound like somebody who tries to convince yourself that it is 'not 
> necessary' to have the 'extra slots' mechanism from Qt3. I believe that Qt4 
> has improved greatly but this is one of the features that I miss greatly.
> 
> Would it not be possible to have 'extra slots' in a widget and assume that 
> these will be provided in the containing widget.

No, the code that designer generates is not anymore a QObject derived
class, so you can't have slots in it. You'd always have to redefine
those slots in your own QWidget derived class.

I personally can't see why you need to create the slots in designer
itself, you don't even need the connect if you name the slots properly
and you'd have to code them anyway to bring in the logic.

> So if I would connect a form 
> button to one of these extra slots, the compiler would connect that button to 
> the named slot in the container (that contains that form). At the moment a 
> similar mechanism exists with the on_<widget>_<signal> list. I think that 
> could be extended as to provide the possibilities of the Qt3 designer.

Having the connect is not enough, you need to code the slot in your
QWidget subclass anyway, so whats the problem with naming it on_XXX_YY?
You'd always have to code the slot in your QWidget derived class, so
there's no benefit defining the slot as well in the .ui file. If uic
would start to change my hand-written QWidget derived class I'd probably
go out hunting for trolls ;)

-- 
 [ signature omitted ] 

Message 5 in thread

> > Would it not be possible to have 'extra slots' in a widget and assume
> > that these will be provided in the containing widget.
>
> No, the code that designer generates is not anymore a QObject derived
> class, so you can't have slots in it. You'd always have to redefine
> those slots in your own QWidget derived class.

Yes I know that, but the class generated by the designer should not expect to 
offer the slots themselves. It should merely assume that the slots will be 
provided by its container. And that must be a QObject anyway.

> I personally can't see why you need to create the slots in designer
> itself, you don't even need the connect if you name the slots properly
> and you'd have to code them anyway to bring in the logic.

I don't want to create slots in the designer, I just want some way to let the 
designer know that certain slots _will_ be offered by the container.

> Having the connect is not enough, you need to code the slot in your
> QWidget subclass anyway, so whats the problem with naming it on_XXX_YY?

If a connection to the container depends on the container using the right 
client widget name then the general purpose connecting system becomes much 
less general. (E.g: any form that should 'calculate' something must have a 
calculate button that is exactly called 'calculate'. Otherwise the container 
will not link to it because it has only a on_calculate_... slot). The 
on_<widget>_<signal>_ connect system seems a bit of a fix and would be much 
more useful if the form itself would connect to a specific slot when it is 
setupUi-ed.

> You'd always have to code the slot in your QWidget derived class, so
> there's no benefit defining the slot as well in the .ui file. If uic
> would start to change my hand-written QWidget derived class I'd probably
> go out hunting for trolls ;)

Of course you need to code your own slots. I don't argue that and I actually 
never used Qt-designer for 'coding' purposes. My main use for it is to 
connect widgets, layout widgets and name widgets. And the interesting stuff: 
connecting various buttons of a form (drawn in the designer) to slots I will 
provide and code later seems missing.

With kind regards,

-- 
 [ signature omitted ] 

Message 6 in thread

On 03.08.07 13:49:49, Werner Van Belle wrote:
> > Having the connect is not enough, you need to code the slot in your
> > QWidget subclass anyway, so whats the problem with naming it on_XXX_YY?
> 
> If a connection to the container depends on the container using the right 
> client widget name then the general purpose connecting system becomes much 
> less general. (E.g: any form that should 'calculate' something must have a 
> calculate button that is exactly called 'calculate'. Otherwise the container 
> will not link to it because it has only a on_calculate_... slot). The 
> on_<widget>_<signal>_ connect system seems a bit of a fix and would be much 
> more useful if the form itself would connect to a specific slot when it is 
> setupUi-ed.

I fail to see the difference. Either all widgets using the form have to
have the on_foo_signal or they have to have the slotFoo so the connect
in setupUi works. I really don't see what problems you've got with on_.. 

> > You'd always have to code the slot in your QWidget derived class, so
> > there's no benefit defining the slot as well in the .ui file. If uic
> > would start to change my hand-written QWidget derived class I'd probably
> > go out hunting for trolls ;)
> 
> Of course you need to code your own slots. I don't argue that and I actually 
> never used Qt-designer for 'coding' purposes. My main use for it is to 
> connect widgets, layout widgets and name widgets. And the interesting stuff: 
> connecting various buttons of a form (drawn in the designer) to slots I will 
> provide and code later seems missing.

No its not, all you have to do is follow a predefined naming scheme.
Either that or code up a few connect calls yourself.

Andreas

-- 
 [ signature omitted ] 

Message 7 in thread

Hi

thanks, it might be therefor I didnt find it. And no it is not much
work, but it is one more thing to do and change when you update a
design.  I liked the id'e that all designing and signal and stuff
where done in the Designer, and then the logic stuff where done in the
IDE, but I can live with this.

thanks for the link, but that guide where the place I where looking
and couldnt find anything

regards
Anders

On 8/3/07, Malte Witt <malte.witt@xxxxxxxxxxxxx> wrote:
> Hi,
>
> this is not the way designer works in Qt4 anymore. While in Qt3 the
> designer had some kind of IDE and Project management features icluded
> those features where stripped in Qt4 designer.
> Now it is "only" a very powerful tool do design your forms - no more - no
> less! It's doing it's job great!!! Everything besides designing the GUI is
> up to the probrammer - and be honest - writing a connect() statement is
> not that much work - is it?
>
> When doing my first steps with Qt4 I thought it would be so much more work
> now - but time showed me, that Qt-programs are way better readable now. I
> really like the new designer. Use it for a while and you will too ;-)
>
> There is a great introduction in the Qt4-designer shipped with Qt4 and
> online at http://doc.trolltech.com/4.3/designer-manual.html .
>
> Hope that helps a bit,
>
> Regards,
> Malte
>
>
>
> "Anders Sandholm" <anders.sandholm@xxxxxxxxx> schrieb am 03.08.2007
> 10:15:51:
>
> > Hi
> >
> > I have just moved to QT 4.3 and it is one rely simple think I just
> > cant figure out. Now in 3.x there where the Add slot function, where
> > new slots where created and then it as extremely easy to create a
> > signal -> slot connection.
> >
> > Now I just cant figure out how I can create slots in QT Designer 4.3,
> > is there a way or do I have to do it manual in the class that inherit
> > my "qt-designer-class". Say for an example I want to connect a button,
> > pb_HelloWorld with the function helloWorld, how do I do this in QT
> > Designer 4.3. Or even worse, I have a menu item, mi_HelloWorld and I
> > want to connect it to a function foo.
> >
> > As I said a really simple question but I can find any information on
> > how to create and manage you own slots either in the
> > manual/tutorial/examples.
> >
> > best regards
> > Anders
> >
> > --
> > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
> > with "unsubscribe" in the subject or the body.
> > List archive and information: http://lists.trolltech.com/qt-interest/
> >
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

--
 [ signature omitted ] 

Message 8 in thread

If you're working with Visual Studio on Windows, the Integration that
comes with the commercial version still allows you to connect signals to
slots (they will be entered directly in the sourcecode).

Cheers,
Peter

> -----Original Message-----
> From: Anders Sandholm [mailto:anders.sandholm@xxxxxxxxx]
> Sent: Friday, August 03, 2007 10:51 AM
> To: Malte Witt
> Cc: qt-interest@xxxxxxxxxxxxx
> Subject: Re: Slot QT Designer 4.3 question
> 
> Hi
> 
> thanks, it might be therefor I didnt find it. And no it is not much
> work, but it is one more thing to do and change when you update a
> design.  I liked the id'e that all designing and signal and stuff
> where done in the Designer, and then the logic stuff where done in the
> IDE, but I can live with this.
> 
> thanks for the link, but that guide where the place I where looking
> and couldnt find anything
> 
> regards
> Anders

--
 [ signature omitted ] 

Message 9 in thread

On 03.08.07 10:50:32, Anders Sandholm wrote:
> Hi
> 
> thanks, it might be therefor I didnt find it. And no it is not much
> work, but it is one more thing to do and change when you update a
> design.  I liked the id'e that all designing and signal and stuff
> where done in the Designer, and then the logic stuff where done in the
> IDE, but I can live with this.

You can have a bit easier time by using auto-connect slots, see the
designer manual for more information about them (save's you the connect
call).

Andreas

-- 
 [ signature omitted ] 

Message 10 in thread

> You can have a bit easier time by using auto-connect slots, see the
> designer manual for more information about them (save's you the connect
> call).

You could if you really like _underscores_ in your method names *shudder*.
Reason enough for me to use a connect() statement ;-)

Regards,
Malte

--
 [ signature omitted ]