[Qt-creator] Problems with Dockwidgets

Eike Ziller eike.ziller at nokia.com
Fri Jan 22 09:32:28 CET 2010


On Jan 22, 2010, at 12:31 AM, ext Ken Ray wrote:

> Looks like my message didn't make it.  
> 
> I found the solution and it definitely related to Creator and to user lack of knowledge of Creator. I'm a bit surprised that I was sent on a wild goose chase to resolve this.
> 
> The answer was surprisingly simple.  All I had to do was modify the minimumSize.Width property to the size that I wanted and the geometry.Width picked it up.  It seems kinda silly to have several different areas to set the width of the widget i'm playing with, Min size, Max size make sense. But adding a geometry completely messed me up here. Can anyone explain what the rational is here .

The relationships in Qt between geometry, size hint, size policy, minimum and maximum size are sometimes not obvious.
Trying to wrap it up a little bit, but be sure that what I say isn't the whole story:
* You have to distinguish between a widget that is added to a layout or not (dockwidgets are in a layout).
* No layout: geometry defines the size of the widget, constrained by minimum and maximum size.
* In a layout: the layout takes the size hint from the widget (a size calculated by the widget itself, in case of a dockwidget that depends on the layouts and widgets inside the dockwidget), and depending on the size policy (http://doc.qt.nokia.com/4.6/qsizepolicy.html#Policy-enum), and depending on all the size hints and policies of other widgets in the layout, calculates the actual size of the widget, which is again constrained by minimum and maximum size. After that the "geometry" property reflects the size of the widget.

So, the moment a widget is contained in a layout, its "geometry" is actually a "read-only" property.

Designer actually sets the geometry property to read-only if you add a widget to a layout. Seems that you hit a bug that Designer doesn't do that when you add a dockwidget to a QMainWindow.

You can find a bit more detail (also mentioning "stretch factors") e.g. here http://doc.qt.nokia.com/4.6/layout.html

> Also, when I set the minimum width I got a vertical line on the right side of the dockWidget... something I've been trying to figure out how the sample did it, but with no luck. 
> 
> So I'm currently back playing with Creator and QT.  Are there be any relevant books or tutorials dealing with this ?
> 
> Ken
> 
> 
> On Jan 21, 2010, at 2:46 PM, Danny Price wrote:
> 
>> We'll still be here when you come back :)
>> 
>> On 21 Jan 2010, at 22:09, Coda Highland wrote:
>> 
>>> On Thu, Jan 21, 2010 at 3:11 PM, Ken Ray <ken at ishere.com> wrote:
>>>> I tried qt-interest and not much of a response. Note that this test app I'm trying to build is just like the fontsampler demo that comes with creator/QT.  I'm trying to duplicate the dockwidget on the left. How did fontsampler get around this problem ?   It seems to me that if Creator can't hold a layout for more than a few clicks there is a serious flaw. It makes working with all the contents related to that dockwidget a pain in the ass.
>>>> 
>>>> I'm going to go play with Mono now to see how there stuff is .
>>>> 
>>>> I want some cross platform development that is stable. but if none is stable , then I guess it's back to VS .net ..
>>> 
>>> Mono is pretty gimped, sadly. Most of the "good" .NET stuff is
>>> Microsoft-only junk that's only available on Windows. Even Java would
>>> be preferable to .NET if you want cross-platform compatibility.
>>> 
>>> You happened to hit on the one thing I don't like about Qt: dock
>>> widgets. I've never had a lot of luck with them, and when I do use
>>> them I develop with code, not Designer. There's several things that
>>> they don't do quite right. But don't let that one widget turn you off
>>> to the toolkit as a whole. Qt's very stable and very robust, and it's
>>> the best toolkit available for writing apps that look native on all
>>> supported platforms.
>>> 
>>> Consider possibly using some other solution if dock widgets in
>>> Designer aren't working for you. Maybe construct the dock widgets in
>>> code, or maybe use some non-docking solution.
>>> 
>>> /s/ Adam
>>> 
>>> _______________________________________________
>>> Qt-creator mailing list
>>> Qt-creator at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-creator
>> 
>> 
>> _______________________________________________
>> Qt-creator mailing list
>> Qt-creator at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-creator
> 
> 
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-creator

-- 
Eike Ziller
Software Engineer
Nokia, Qt Development Frameworks

Nokia gate5 GmbH
Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany
Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B
Umsatzsteueridentifikationsnummer: DE 812 845 193
Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori







More information about the Qt-creator-old mailing list