|
|
Andreas Pakulat schrieb:
> On 13.02.08 16:57:58, Jorge wrote:
>
>> Andreas Pakulat schrieb:
>>
>>> On 07.02.08 22:33:01, Ionathan wrote:
>>>
>>>
>>>> Hi group,
>>>>
>>>> I am playing around with stacked widgets the ultimate goal being to get
>>>> the "connectSlotByName" - mechanism work.
>>>>
>>>> Now the attached code is a simple application where I use two - very
>>>> similar - .ui files for stacking on a mainwindow-application.
>>>>
>>>> it shows the main widgets. however the .ui widgets do not show up ...
>>>>
>>>> What did I do wrong? The attached code compiles nicely and runs but ...
>>>>
>>>>
>>> About everything. Sorry. I know you're probably just starting, but you
>>> really need to go back to the start and read again the designer manual
>>> and possibly also check some of the examples.
>>>
>>> A few things that are wrong:
>>>
>>> - mainwindow inherits from both .ui files
>>> - the 2 classes that use the .ui files, are both QDialogs and thus
>>> themselves top level windows, not embedded anywhere
>>> - you create 2 empty QWidgets and put those into the stack, how can you
>>> expect them to show anything, except their background.
>>>
>>>
>>>
>> Thanks Andreas, I was a bit absent, now in the meantime I got something
>> to work better, however it still does not switch the widgets ... If you
>> would be so kind as to look over the attached files? should not be too
>> much work ... tia Jorge
>>
>
> Two problems:
>
> a) firstform.h: the class first subclasses from the ui-class, that won't
> work. QObject subclasses always have to subclass from their
> QObject-parent first (i.e. QWidget here)
>
> b) your calling setupUi() with the parent that gets passed into your
> widgets, which means all the ui from the .ui files gets done _onto_ that
> parent widget - in your case the mainwindow. So everything actually
> works correctly, just that the two widgets you add to the stacked widget
> are simply empty.
>
> Its also a good habit to call the paren class constructor, especially
> QWidget to pass the parent parameter on to it so your QWidget subclass
> ends up in the right parent (if any).
>
> It still looks as if you'd want to re-read some of the basic chapters in
> the Qt documentation, especially about the object model, layout
> management and probably the designer manual.
>
> Andreas
>
>
Thanks Andreas - now it works and the slots in the ui-derived subclasses
(firstform.h and secondform.h) will be addressed from clicks in the
pushbutton widgets I added in the respective ui's.
The only thing which does not show up is the background color I put to
the ui's (just for fun). But this is worth another thread.
Jörg
--
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/
|
|