Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, August 2007
Problems with the size of a custom widget


Message 1 in thread

I am trying to build a custom widget and I'm having trouble making it
stay the size I want. I included a screenshot of what the widget
currently looks like.

The widget is meant to act like a spinner that can count from 1 to 10.
Its appearance is set to match the one on the character sheets the
forms I'll put it on are meant to emulate. You can look here to see
the visual I want:
http://www.camarillaprovidence.org/Requiem/RequiemSheet.php

I'm currently working in Designer to try to make the widget look as I
want it to. The problems is that radio boxes won't stay 16x16 once
they are horizontally layouted, they'll expend to a width of 24 to
include a non-existing text.

The button on the left is meant to toggle the widget between 5 and 10
slots (one row or two), I can't manage to make it tiny, it expends to
the current size when layouted too.

Should I just stop using layouts or could it mess up my display on
other platforms?

Thanks for any help.

Attachment:

Attachment: custom widget.png
Description: PNG image


Message 2 in thread

On mandag den 6. August 2007, Dan wrote:
> I am trying to build a custom widget and I'm having trouble making it
> stay the size I want. I included a screenshot of what the widget
> currently looks like.
>
> The widget is meant to act like a spinner that can count from 1 to 10.
> Its appearance is set to match the one on the character sheets the
> forms I'll put it on are meant to emulate. You can look here to see
> the visual I want:
> http://www.camarillaprovidence.org/Requiem/RequiemSheet.php
>
> I'm currently working in Designer to try to make the widget look as I
> want it to. The problems is that radio boxes won't stay 16x16 once
> they are horizontally layouted, they'll expend to a width of 24 to
> include a non-existing text.

Yes. Without tricks, you can't get this working. It's impossible.

> The button on the left is meant to toggle the widget between 5 and 10
> slots (one row or two), I can't manage to make it tiny, it expends to
> the current size when layouted too.
>
> Should I just stop using layouts or could it mess up my display on
> other platforms?

In this case, you might actually do without layouts. But you will still have 
problems because of changing font sizes etc.

My favourite trick for something like this is to subclass the QStyle and 
modify the sizing of the widget parts. You could make your own style and just 
set it on these specific widgets. It won't look correct in designer unless 
you make a style plugin.

This reminds me that I really want to send a bug report to the trolls. The 
radiobuttons shouldn't (IMHO) set that extra horizontal space, if the text is 
empty.

For the button: Try using a QToolButton.

Bo.

-- 
 [ signature omitted ] 

Message 3 in thread

Try this .ui file.  I think it does what you want if I'm understanding
you correctly.  The biggest thing I did was set the radio buttons'
sizePolicy to Fixed,Fixed, and set their min and max sizes to 16x16.  I
also took the grid layout that the 10 radio buttons are inside of and
changed the widget spacing to 0 to put them tighter together.

Sean

-----Original Message-----
From: Dan [mailto:redalastor@xxxxxxxxx] 
Sent: Monday, August 06, 2007 4:29 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Problems with the size of a custom widget

I am trying to build a custom widget and I'm having trouble making it
stay the size I want. I included a screenshot of what the widget
currently looks like.

The widget is meant to act like a spinner that can count from 1 to 10.
Its appearance is set to match the one on the character sheets the forms
I'll put it on are meant to emulate. You can look here to see the visual
I want:
http://www.camarillaprovidence.org/Requiem/RequiemSheet.php

I'm currently working in Designer to try to make the widget look as I
want it to. The problems is that radio boxes won't stay 16x16 once they
are horizontally layouted, they'll expend to a width of 24 to include a
non-existing text.

The button on the left is meant to toggle the widget between 5 and 10
slots (one row or two), I can't manage to make it tiny, it expends to
the current size when layouted too.

Should I just stop using layouts or could it mess up my display on other
platforms?

Thanks for any help.

Attachment:

Attachment: test.ui
Description: test.ui