PDA

View Full Version : problem with Tool button n Layout



arjunasd
24th July 2007, 17:45
Hi all

I am new to Qt and I used Designer to form a dialog. It looks good in the preview. But when I subclass it and use in a program, I have one the tool butttons alone elongated. The rest are all fine. I have attached the screenshot for reference. The problem is with the button in 3rd row and 2nd column. I did not write any code to change the size at all.

What could be the reason? Kindly help me.

Arjun

marcel
24th July 2007, 18:36
What layout did you use?
I think it is better if you'd post the UI.

arjunasd
24th July 2007, 18:53
I used a Grid layout. I have attached my UI.

Also, one more question, is there a way to allign the tool buttons to the center of each grid?

Thanks
Arjun

marcel
24th July 2007, 19:13
Everything seems alright, except that you don't have a top level layout.
Maybe there's something wrong in your code.
How do you set those images for the buttons? Do you alter their sizes in any way?
Are the images all the same size?



Also, one more question, is there a way to allign the tool buttons to the center of each grid?

Not sure what you mean.
Do you want them to be horizontally centered relatively to the top labels?

Regards

arjunasd
24th July 2007, 19:17
Everything seems alright, except that you don't have a top level layout.
Maybe there's something wrong in your code.
How do you set those images for the buttons? Do you alter their sizes in any way?
Are the images all the same size?


I just have these 2 components in the dialog. Should I have a top level layout compulsarily?
No I do not alter their sizes.
Yes. All are of the same image size.



Not sure what you mean.
Do you want them to be horizontally centered relatively to the top labels?


Yes. Horizontally center aligned.

Thanks
Arjun

marcel
24th July 2007, 19:52
Use this one.
The layout got pretty complex, but it works.

May I suggest that instead of using two columns of buttons use only one and select with a combo box or a check box whether you're modifying the stroke or fill color?

Regards

arjunasd
24th July 2007, 20:20
Use this one.
The layout got pretty complex, but it works.


I did not get you. Use which one? Did you attach any file to the message. I do not see it. If you dont mind can you attach it again.


May I suggest that instead of using two columns of buttons use only one and select with a combo box or a check box whether you're modifying the stroke or fill color?

Thanks for the suggestion. But I still would like it this way.

marcel
24th July 2007, 20:28
:)
Sorry. I forgot to upload it. Must be the heat.

Here's the attachment too.

Regards

arjunasd
24th July 2007, 20:59
Thanks a lot. It works perfect now.

Also, one final question: How to make the dialog to have a fixed size. I made the sizepolicy to be [Fixed,Fixed,0,0] but still it grows.

So I am not sure how to make it of fixed size?

Thanks
Arjun

marcel
24th July 2007, 21:02
Use the following code in the constructor of the QDialog subclass:



setFixedSize(sizeHint());

This is a common solution.

Another, better solution, but requires a top level layout (you have one ), is:


layout()->setSizeConstraint(QLayout::FixedSize);

This will keep the dialog at a fixed size, but it will also adjust the size in some situations, like when the system font changes.

Regards

arjunasd
24th July 2007, 21:05
Great help man. Thanks a lot.

marcel
24th July 2007, 21:14
You're welcome.