Qt-interest Archive, January 2007
fixed size: I am goind mad
Message 1 in thread
I want to have window, which user can not resize,
except press special button on this window.
So the first approach was, in construstructor of window:
class MDIChild : public QWidget {};
class Window : public MDIChild {
Window(...) {
//some code
setFixedSize(size());
}
};
+window appear without maximize button in system menu
+user can not change it size
-this is not correctly works with layout on window,
some buttons become lay on another widgets,
-when I try to change size using special button,
layout on widget become really crazy.
The first "-" I can fix by:
show();
hide();
before setFixedSize,
but the second "-" imposible to fix.
so I try another appoach:
layout()->setSizeConstraint(QLayout::SetFixedSize);
- there is maximize button, it do not work, but it exists
the second "-" appears only on one of two machines,
both uses qt 4.1.4
the window contains "tab widget",
user can choose to see one tab or 4 tabs with different content,
by default user can see one tab,
and when he choose see 4 tabs:
on the first machine size of window is change to minimum of needed size
on the second machine size of window is change to MEGA big size( a
couple of screen or so).
So questions:
1)Is any more right way to do not allow to user change window size,
but to make possible "Layout" to handle things in right way?
2)Is any way to debug QT "Layout" logic?
--
[ signature omitted ]
Message 2 in thread
Applying the same size for both:
setMinimumSize
setMaximumSize
to block window resizing.
Lingfa
>
> 1)Is any more right way to do not allow to user change window size,
> but to make possible "Layout" to handle things in right way?
--
[ signature omitted ]
Message 3 in thread
Thanks for reply.
What this difference between usage of setFixedSize?
This is also blocks work of "Layout".
On 1/25/07, lingfa <lingfa@xxxxxxxxxxxx> wrote:
> Applying the same size for both:
> setMinimumSize
> setMaximumSize
This blocks, but this also make unpossible to resize window in programming
way, and on machine with different fonts, after start one widget
partly lay on another.
> to block window resizing.
>
> Lingfa
>
> >
> > 1)Is any more right way to do not allow to user change window size,
> > but to make possible "Layout" to handle things in right way?
>
>
>
--
[ signature omitted ]
Message 4 in thread
On Wednesday 24 January 2007 21:57, Tomasz Kvarsin wrote:
> I want to have window, which user can not resize,
> except press special button on this window.
>
> So the first approach was, in construstructor of window:
> class MDIChild : public QWidget {};
> class Window : public MDIChild {
> Window(...) {
> //some code
Probably you need an additional
adjustSize();
before setting the size.
> setFixedSize(size());
> }
> };
>
--
[ signature omitted ]
Message 5 in thread
On 1/25/07, Matthias Toussaint <toussaint@xxxxxxxxx> wrote:
> On Wednesday 24 January 2007 21:57, Tomasz Kvarsin wrote:
> > I want to have window, which user can not resize,
> > except press special button on this window.
> >
> > So the first approach was, in construstructor of window:
> > class MDIChild : public QWidget {};
> > class Window : public MDIChild {
> > Window(...) {
> > //some code
> Probably you need an additional
> adjustSize();
> before setting the size.
>
This make things worse,
if call only
setFixedSize(size());
things become bad only on another machine with differents fonts,
if write
adjustSize();
setFixedSize(size());
The almost all widgets lay on another widgets.
--
[ signature omitted ]
Message 6 in thread
Tomasz Kvarsin wrote:
> On 1/25/07, Matthias Toussaint <toussaint@xxxxxxxxx> wrote:
>> On Wednesday 24 January 2007 21:57, Tomasz Kvarsin wrote:
>> > I want to have window, which user can not resize,
>> > except press special button on this window.
>> >
>> > So the first approach was, in construstructor of window:
>> > class MDIChild : public QWidget {};
>> > class Window : public MDIChild {
>> > Window(...) {
>> > //some code
>> Probably you need an additional
>> adjustSize();
>> before setting the size.
>>
>
> This make things worse,
> if call only
> setFixedSize(size());
>
> things become bad only on another machine with differents fonts,
>
> if write
> adjustSize();
> setFixedSize(size());
>
> The almost all widgets lay on another widgets.
>
Sounds like you are missing layouts.... on your dialog. Do you have a
compilable example?
--Justin
begin:vcard
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:(617) 621-0060
url:http://www.ics.com
version:2.1
end:vcard
Message 7 in thread
On 1/25/07, Justin Noel <justin@xxxxxxx> wrote:
> Tomasz Kvarsin wrote:
> > On 1/25/07, Matthias Toussaint <toussaint@xxxxxxxxx> wrote:
> >> On Wednesday 24 January 2007 21:57, Tomasz Kvarsin wrote:
> >> > I want to have window, which user can not resize,
> >> > except press special button on this window.
> >> >
> >> > So the first approach was, in construstructor of window:
> >> > class MDIChild : public QWidget {};
> >> > class Window : public MDIChild {
> >> > Window(...) {
> >> > //some code
> >> Probably you need an additional
> >> adjustSize();
> >> before setting the size.
> >>
> >
> > This make things worse,
> > if call only
> > setFixedSize(size());
> >
> > things become bad only on another machine with differents fonts,
> >
> > if write
> > adjustSize();
> > setFixedSize(size());
> >
> > The almost all widgets lay on another widgets.
> >
>
> Sounds like you are missing layouts.... on your dialog. Do you have a
> compilable example?
>
I have layouts, I have many many layouts. Compilable example try to get,
but I find the bug, some widgets are custom, and of their contructors also call
setFixedSize(size()) for this widget, I remove this line and such combination
in my Window constuctor now works
adjustSize();
setFixedSize(size());
but actully this is solution only for hack like this:
show();
hide();
setFixedSize();
but still the main problem:
I want to not allow user change windows size,
but program should can do it, and I do not calc new size by myself,
for example dialog with QLabel with variable size caption.
If any have idea how to solve this, it would be great.
I try to play with adjustSize,
I added signal to my custom widget to inform about size changes,
and slot in my window to hande this situation like this:
setMinimumSize(size().width() - 200, size().height());
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
//layout()->update();
adjustSize();
setFixedSize(size());
but this sometimes work,
1)when I increase size of widget
2)when I decrease and then again decrease size of widget
but when I once decrease size of widget this doesn't work :(
--
[ signature omitted ]
Message 8 in thread
Tomasz Kvarsin wrote:
> but still the main problem:
> I want to not allow user change windows size,
> but program should can do it, and I do not calc new size by myself,
OK. There _should_ be two ways to do this:
1. Call setSizeConstraint(QLayout::SetFixedSize) on the window's layout.
2. Call setFixedSize() on the window itself.
The second way is probably not what you want because you don't know in
advance how big the window needs to be.
> for example dialog with QLabel with variable size caption.
The first way (with the size constraint) should handle this.
> If any have idea how to solve this, it would be great.
>
> I try to play with adjustSize,
> I added signal to my custom widget to inform about size changes,
> and slot in my window to hande this situation like this:
If you can, you should let the layout handle changes to the size caused by
child widgets. Problems may arise when you have conflicting constraints
caused by fixed size child widgets. If there are too many constraints then
there may be no way to satisfy them all.
I tried your example code, and I saw the problem with overlapping widgets,
but I didn't understand what you _wanted_ to see instead.
David
--
[ signature omitted ]
Message 9 in thread
On 1/30/07, David Boddie <dboddie@xxxxxxxxxxxxx> wrote:
> Tomasz Kvarsin wrote:
>
> > but still the main problem:
> > I want to not allow user change windows size,
> > but program should can do it, and I do not calc new size by myself,
>
> OK. There _should_ be two ways to do this:
>
> 1. Call setSizeConstraint(QLayout::SetFixedSize) on the window's layout.
> 2. Call setFixedSize() on the window itself.
>
> The second way is probably not what you want because you don't know in
> advance how big the window needs to be.
>
May be I do not understand, by how it is possible to know how big window needs
to be? On different platforms default font may have different sizes,
and reaction on font appear after widget will be constructed.
The problem of (2) and (3) [Call setFixedSize in showEvent]
works, but the devil is in the details:
that maximum button appears, and do not possible to remove it
for not toplevelwindow,
or I missing something?
> > for example dialog with QLabel with variable size caption.
>
> The first way (with the size constraint) should handle this.
>
> > If any have idea how to solve this, it would be great.
> >
> > I try to play with adjustSize,
> > I added signal to my custom widget to inform about size changes,
> > and slot in my window to hande this situation like this:
>
> If you can, you should let the layout handle changes to the size caused by
> child widgets. Problems may arise when you have conflicting constraints
> caused by fixed size child widgets. If there are too many constraints then
> there may be no way to satisfy them all.
>
> I tried your example code, and I saw the problem with overlapping widgets,
> but I didn't understand what you _wanted_ to see instead.
>
I just want that "red" widget occupy so much space as I want,
and widgets should not overlap.
--
[ signature omitted ]
Message 10 in thread
Here is compilable example:
http://www.4shared.com/dir/1891004/e4f86257/sharing.html
qt-fixed-size.zip
contains
badui.h - generate by qt build system ui_*.h file,
little modified to simlify things
mywidget.[ch]pp - custom widget
and mainwin - window which uses badui.h.
archive also contains qmake project file to build and
Makefile for my system, may be you need regenerate it to use.
And such consequence:
adjustSize
setFixedSize
cause that one widget lay on another.
may be this is a bug, and I should report it to trolltech?
On 1/25/07, Justin Noel <justin@xxxxxxx> wrote:
> Tomasz Kvarsin wrote:
> > On 1/25/07, Matthias Toussaint <toussaint@xxxxxxxxx> wrote:
> >> On Wednesday 24 January 2007 21:57, Tomasz Kvarsin wrote:
> >> > I want to have window, which user can not resize,
> >> > except press special button on this window.
> >> >
> >> > So the first approach was, in construstructor of window:
> >> > class MDIChild : public QWidget {};
> >> > class Window : public MDIChild {
> >> > Window(...) {
> >> > //some code
> >> Probably you need an additional
> >> adjustSize();
> >> before setting the size.
> >>
> >
> > This make things worse,
> > if call only
> > setFixedSize(size());
> >
> > things become bad only on another machine with differents fonts,
> >
> > if write
> > adjustSize();
> > setFixedSize(size());
> >
> > The almost all widgets lay on another widgets.
> >
>
> Sounds like you are missing layouts.... on your dialog. Do you have a
> compilable example?
>
> --Justin
>
>
>
--
[ signature omitted ]
Message 11 in thread
On 1/29/07, Clemens Clausen <clausecs@xxxxxxxxxxxxxxxxxx> wrote:
> Hello,
>
> is it possible to set the size within the paintEvent()? I experienced
> similar behavior with layouts and widgets and I got mad, too. Then, a
> colleague advised me to set sizes within paintEvent()s. Qt seems to
> rearrange/recalculate the sizes of the layout and its widgets while they
> are constructed and in my case, they get their correct size first in the
> paintEvent. I have to admit that I never really understood the sequence
> of events which are called during the construction of such widgets in
> depth, so this is just a little hint (written by a qt-noob) why your
> function calls may not work. Maybe, calling an update or repaint could
> help there, but I had no need to try something like that.
> I guess this behavior is well-known and therefore I don't think that it
> is worth to report...
>
Thanks this works, I used showEvent to call setFixedSize,
but actually the idea of calling adjustSize was that
yes, constructor is wrong place to fixate size,
so we enforce layout update
via adjustSize and then use setFixedSize.
But seems to me that adjustSize not for that.
The small issue that maximized button in system menu appear, but do not work,
the funny thing that it is not appear if call setFixedSize in constructor.
> Regards, Clemens
>
> Tomasz Kvarsin wrote:
> > Here is compilable example:
> > http://www.4shared.com/dir/1891004/e4f86257/sharing.html
> >
> > qt-fixed-size.zip
> > contains
> > badui.h - generate by qt build system ui_*.h file,
> > little modified to simlify things
> > mywidget.[ch]pp - custom widget
> > and mainwin - window which uses badui.h.
> >
> > archive also contains qmake project file to build and
> > Makefile for my system, may be you need regenerate it to use.
> >
> > And such consequence:
> > adjustSize
> > setFixedSize
> >
> > cause that one widget lay on another.
> >
> > may be this is a bug, and I should report it to trolltech?
> >
> > On 1/25/07, Justin Noel <justin@xxxxxxx> wrote:
> >> Tomasz Kvarsin wrote:
> >> > On 1/25/07, Matthias Toussaint <toussaint@xxxxxxxxx> wrote:
> >> >> On Wednesday 24 January 2007 21:57, Tomasz Kvarsin wrote:
> >> >> > I want to have window, which user can not resize,
> >> >> > except press special button on this window.
> >> >> >
> >> >> > So the first approach was, in construstructor of window:
> >> >> > class MDIChild : public QWidget {};
> >> >> > class Window : public MDIChild {
> >> >> > Window(...) {
> >> >> > //some code
> >> >> Probably you need an additional
> >> >> adjustSize();
> >> >> before setting the size.
> >> >>
> >> >
> >> > This make things worse,
> >> > if call only
> >> > setFixedSize(size());
> >> >
> >> > things become bad only on another machine with differents fonts,
> >> >
> >> > if write
> >> > adjustSize();
> >> > setFixedSize(size());
> >> >
> >> > The almost all widgets lay on another widgets.
> >> >
> >>
> >> Sounds like you are missing layouts.... on your dialog. Do you have a
> >> compilable example?
> >>
> >> --Justin
> >>
> >>
> >>
> >
> > --
> > 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 12 in thread
On 1/29/07, Clemens Clausen <clausecs@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > The small issue that maximized button in system menu appear, but do
> > not work,
> > the funny thing that it is not appear if call setFixedSize in
> > constructor.
> I'm not sure, but perhaps, it will succeed to set maximumSize(), a
> sizeHint() and minimumSize()?
actually, setfixedsize do it, I mean set maximum and minimum size.
"Maximize button" do not work, but it appears.
> Then, the maximize button shall expand to
> the windows maximumSize() and the sizeHint() should define the default
> size. Otherwise, there are perhaps some Qt::WindowFlags to suppress this
> button like Qt::WindowMaximizeButtonHint.
It is for top-level window, my window is mdi child.
>I do not know much about that,
Your hint about setfixedsize in paintEvent was(is) great.
--
[ signature omitted ]