You are not logged in.

1

Wednesday, July 13th 2005, 3:07am

Fixed size dialog

Hi,

I'm wondering what the proper way is to make a dialog of fixed size. I have a dialog with a set of line edit fields, and it seems pretty pointless to let users stretch it, it would only make it less readable. So I figured I would make it fixed size. However, the only way I've found to do it is set the vsizetype and hsizetype to 'fixed' and then start guessing a pixel count in minimumSize/maximumSize/baseSize.. This seems like a hopeless way to do things, surely there is some more organized way to set a fixed size (like a 'fixedSize = true' option ;-))
I just want it to fit my controls.. Trial and error lets me find the right size now, but if I would add another field it would mean having to do it all over again. A maintenance nightmare..

Regards,
PV
Peter Vel

"I can't remember if I'm the good twin or the evil one."

2

Wednesday, July 13th 2005, 8:43am

RE: Fixed size dialog

Quoted

... and then start guessing a pixel count in minimumSize/maximumSize/baseSize.

In QT designer edit mode you can stretch your dialog so that it fits your needs.
look at the properties > geometry and you have the h and v values you try to get by guessing.

Quoted

I have a dialog with a set of line edit fields, and it seems pretty pointless to let users stretch it

Keep in mind that labels can stretch when you translate your program. This means also that the lineedits can shrink if your dialog size is limited by it's size policy. Is this really what you want?

Quoted

I just want it to fit my controls.. Trial and error lets me find the right size now, but if I would add another field it would mean having to do it all over again.

If you're sure things will remain as they are you can use a dialog with fixed size. But you tell us it is possible that you will add other widgets, so you don't know at this point where you will end. In this case I think you will be better off letting QT determine the size of your dialog using the sizehints of the widegets you use.

Cheers

3

Wednesday, July 13th 2005, 10:28am

You should also keep in mind that not all users have the same system font and font size.

So, if you want a fixed sized dialog that actually works, you'll have to calculate the size of the dialog on start-up.

chickenblood

Professional

Posts: 657

Location: Mountain View, CA

Occupation: Data Monkey

  • Send private message

4

Wednesday, July 13th 2005, 4:39pm

The actual answer is to apply a layout to your dialog and set the resizeMode property to 'fixed'. This will handle any issues with fonts, i18n, etc.

Most people miss this (see above).
I have enough sense to know that "common sense" is an oxymoron.

This post has been edited 1 times, last edit by "chickenblood" (Jul 13th 2005, 4:39pm)


5

Thursday, July 14th 2005, 3:13pm

@chickenblood

Quoted

The actual answer is to apply a layout to your dialog and set the resizeMode property to 'fixed

I guess you are referring to the sizePolicy property?

fixed means the dialog will show up at its sizehint. But with sizePolicy fixed it's still possible to stretch it and make it bigger.
Peter Vel asked for a really fixed dialog in the first thread in this post.

The Qt terminology fixed is different from the meaning of the English word "fixed".
I think this causes discussions like this.

Cheers

chickenblood

Professional

Posts: 657

Location: Mountain View, CA

Occupation: Data Monkey

  • Send private message

6

Thursday, July 14th 2005, 5:08pm

Quoted

Originally posted by Everall
@chickenblood

Quoted

The actual answer is to apply a layout to your dialog and set the resizeMode property to 'fixed

I guess you are referring to the sizePolicy property?


No, I'm referring to the resizeMode property.

Quoted


fixed means the dialog will show up at its sizehint. But with sizePolicy fixed it's still possible to stretch it and make it bigger.

Not with 'resizeMode' set to 'Fixed'. The dialog size is fixed at its size hint. It cannot be resized.

Quoted


Peter Vel asked for a really fixed dialog in the first thread in this post.

Yes I know! That is what I am offering him.

Quoted


The Qt terminology fixed is different from the meaning of the English word "fixed".

Not really.

Peter, I suggest you try this, because I use this method all the time and it works.
I have enough sense to know that "common sense" is an oxymoron.

This post has been edited 2 times, last edit by "chickenblood" (Jul 14th 2005, 5:09pm)


7

Friday, July 15th 2005, 8:46am

@Chickenblood
Yes, you're right it works that way. Thanks for pointing that out again and again and again. I missed that ;)

As you said, In QT3 designer, after you used Layout in a grid, you can find the resizeMode property and set it fixed there.
(2 other layout properties appear also in the dialog properties : LayoutSpacing and LayoutMargin)

In QT4 it is not available in the property editor when we make a Layout in a grid.(QT4.0.0)
So we need code to do it.

After some investigation i found :

In QT3
QLayout::setResizeMode(QLayout::Fixed)

has to be replaced in QT4 by
QLayout::setSizeConstraint(QLayout::setFixedSize)

I searched http://www.trolltech.com/developer/tasktracker.html for sizeConstraint, but this hasn't been posted yet, I'll send a wish/bug report to make the sizeConstraint property avalable in QT4 designer.

Cheers