OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Appropriate resizing of QT dialogs and such, Suggestions on how to make this work?
vanstrien
post Nov 11 2004, 03:56 AM
Post #1





Group: Members
Posts: 58
Joined: 22-August 03
From: Houston / London
Member No.: 374



Hope this isn't too much of a newbie QT question...

On all my dialog boxes based on QDialog, QMessageBox or QWidget I have a fairly consistent problem with incorrect resizing of the windows. Essentially if I design a window Designer which looks just fine, when I then compile and run the app with the window for an 860 some of the text or other objects are obscured. Essentially the window is not resizing/expanding in response to different size fonts, etc.

Of course if I resize the window in Designer to fit well to the 860, then it looks way too big on a 5500. What am I missing to make the whole window automatically resize as needed?

I use vertica and horizontal layouts extensively. I have also tried extra calls to resize() and have reimplemented it to handle some specific requirements.
Go to the top of the page
 
+Quote Post
clivel
post Nov 11 2004, 12:16 PM
Post #2





Group: Members
Posts: 84
Joined: 3-October 03
From: Vancouver, BC
Member No.: 560



Hi,
I don't use Designer, instead I position all the controls manually in the Dialog constructor. The postion and size of the controls is calculated according to the screen resolution. This is painful, but seems to provide the best way of ensuring that everything fits just how I like.
I am not a great fan of layouts, in my experience, they seem to often do an adequate but not very good job of creating a nice looking screen.
Regards,
Clive
Go to the top of the page
 
+Quote Post
ashikase
post Nov 11 2004, 03:19 PM
Post #3





Group: Members
Posts: 280
Joined: 17-March 04
From: Osaka, Japan
Member No.: 2,375



Vanstrien:

It's hard to tell what the problem might be without seeing the code. If the generated GUI code is small enough you might try posting it here, or just provide a link to it.

One thing you might want to check, though... did you make sure to add a layout to the root dialog? In other words, when you select 'new' in QtDesigner, it gives you a blank root dialog to place your widgets in. Once you've laid out all your widgets, make sure to right-click on the root dialog and select a layout. Everything must be inside a layout for resizing to work properly.

- ashikase
anpachi, gifu, japan
Go to the top of the page
 
+Quote Post
vanstrien
post Nov 11 2004, 03:31 PM
Post #4





Group: Members
Posts: 58
Joined: 22-August 03
From: Houston / London
Member No.: 374



Thanks Ashikase.

I used to do my dialog development the same as you: writing the code rather than using Designer to setup a base class. I just started using Designer as some of my interfaces became more complex (and so I could learn something new)

I do have some code that I can use as an example, but I will need to extract it into something worth looking at. I appreciate your help and will repost something as soon as I can.
Go to the top of the page
 
+Quote Post
ashikase
post Nov 11 2004, 06:18 PM
Post #5





Group: Members
Posts: 280
Joined: 17-March 04
From: Osaka, Japan
Member No.: 2,375



vanstrien:

I think you misunderstood... I use QtDesigner as well. What I meant was that you should post the code that uic generates from the .ui file(s). Alternatively, you could just post the .ui file itself.

- ashikase
anpachi, gifu, japan
Go to the top of the page
 
+Quote Post
vanstrien
post Nov 12 2004, 04:23 AM
Post #6





Group: Members
Posts: 58
Joined: 22-August 03
From: Houston / London
Member No.: 374



(ashikase, I got your post and clivel's mixed up. Thus the reference to non-designer apps)

I think I am (slowly) starting to understand how it works.

I've added a call to
CODE
resize(sizeHint())
which I hadn't done previously. This seems to handle resizing especially well for the 240x320 display. I used to do something similar when I coded without Designer.

Is that the best way to handle resizes? And do you have to do something similar to ensure that the window is completely visible?

A quick sample app is here: all.tgz with the .ui code pasted below. With the resize this appears to work, but I often get the title of the dialog off the screen.

CODE
<!DOCTYPE UI><UI>
<class>exampleBoxBase</class>
<widget>
   <class>QDialog</class>
   <property stdset="1">
       <name>name</name>
       <cstring>exampleBoxBase</cstring>
   </property>
   <property stdset="1">
       <name>geometry</name>
       <rect>
           <x>0</x>
           <y>0</y>
           <width>272</width>
           <height>316</height>
       </rect>
   </property>
   <property stdset="1">
       <name>caption</name>
       <string>exampleBox</string>
   </property>
   <vbox>
       <property stdset="1">
           <name>margin</name>
           <number>11</number>
       </property>
       <property stdset="1">
           <name>spacing</name>
           <number>6</number>
       </property>
       <widget>
           <class>QGroupBox</class>
           <property stdset="1">
               <name>name</name>
               <cstring>GroupBox9</cstring>
           </property>
           <property stdset="1">
               <name>title</name>
               <string>test</string>
           </property>
           <vbox>
               <property stdset="1">
                   <name>margin</name>
                   <number>11</number>
               </property>
               <property stdset="1">
                   <name>spacing</name>
                   <number>6</number>
               </property>
               <widget>
                   <class>QLabel</class>
                   <property stdset="1">
                       <name>name</name>
                       <cstring>TextLabel1</cstring>
                   </property>
                   <property stdset="1">
                       <name>text</name>
                       <string>Ad os et bene humo exerci molior et premo. Esse erat iusto vulputate magna molior odio ingenium. Dolore defui, melior fatua feugiat gemino commoveo.</string>
                   </property>
                   <property stdset="1">
                       <name>alignment</name>
                       <set>WordBreak|AlignVCenter|AlignLeft</set>
                   </property>
                   <property>
                       <name>wordwrap</name>
                   </property>
               </widget>
           </vbox>
       </widget>
       <widget>
           <class>QGroupBox</class>
           <property stdset="1">
               <name>name</name>
               <cstring>GroupBox10</cstring>
           </property>
           <property stdset="1">
               <name>title</name>
               <string>sample</string>
           </property>
           <vbox>
               <property stdset="1">
                   <name>margin</name>
                   <number>11</number>
               </property>
               <property stdset="1">
                   <name>spacing</name>
                   <number>6</number>
               </property>
               <widget>
                   <class>QMultiLineEdit</class>
                   <property stdset="1">
                       <name>name</name>
                       <cstring>MultiLineEdit1</cstring>
                   </property>
                   <property stdset="1">
                       <name>wordWrap</name>
                       <enum>WidgetWidth</enum>
                   </property>
                   <property stdset="1">
                       <name>text</name>
                       <string>Ut duis vicis ullamcorper et duis duis caecus esse, dolus, venio incassum cui. Praemitto reprobo nullus capio secundum, aliquip exputo adipiscing facilisi pneum, obruo refero, quidem. </string>
                   </property>
               </widget>
           </vbox>
       </widget>
       <widget>
           <class>QPushButton</class>
           <property stdset="1">
               <name>name</name>
               <cstring>Leave</cstring>
           </property>
           <property stdset="1">
               <name>text</name>
               <string>Leave</string>
           </property>
       </widget>
   </vbox>
</widget>
<connections>
   <connection>
       <sender>Leave</sender>
       <signal>clicked()</signal>
       <receiver>exampleBoxBase</receiver>
       <slot>reject()</slot>
   </connection>
</connections>
</UI>
Go to the top of the page
 
+Quote Post
ashikase
post Nov 12 2004, 04:51 AM
Post #7





Group: Members
Posts: 280
Joined: 17-March 04
From: Osaka, Japan
Member No.: 2,375



I took a look at your example code, though I'm not quite sure what you want it to do. Is it supposed to create the examplebox as a separate dialog (i.e. not a part of the main dialog that contains the lattice)? If so, and you want the new dialog to fit on the screen, I would suggest calling
CODE
box->showMaximized()

instead of
CODE
box->show()

If you do not want the dialog to fill the whole screen, you will have to resize it manually.

On a side note, in main, you do not need to call mw->show, as showMainWidget() already does that for you.

- ashikase
anpachi, gifu, japan
Go to the top of the page
 
+Quote Post
vanstrien
post Nov 12 2004, 08:22 AM
Post #8





Group: Members
Posts: 58
Joined: 22-August 03
From: Houston / London
Member No.: 374



Thanks. But the problem with this example code is the same problem I've having in all my normal code. I think that my use of dialog boxes is missing something. In this example I've been able to get the dialog to resize so that all the text is shown properly by putting a resize(sizeHint()) in the constructor. Is that what you should normally do?

I'm looking for a way of making my dialog boxes so that they work pretty much the same on a 240x320 screen as they do on the 640x480 screen. (or validation that the resize is the right way) If I make a dialog larger in Designer, then it may fit on an 860 but is way too big on a 500. If I shrink the dialog it is the opposite. By calling resize I now have the problem where half the time the title bar is off screen.

A better question might be: besides calling show(), is there anything else you should do to make sure that the a dialog box displays as well as possible? Does it make sense to call a resize() just to ensure that the dialog displays correctly on different screen sizes? (versus setting size policies or something else)
Go to the top of the page
 
+Quote Post
ashikase
post Nov 12 2004, 05:20 PM
Post #9





Group: Members
Posts: 280
Joined: 17-March 04
From: Osaka, Japan
Member No.: 2,375



I'm still not sure that I follow you. You want to make sure that your dialog boxes fit on the screen, but you're saying that you don't want it to be full screen (maximized)? Calling showMaximized() would put the dialog box in maximized mode, so that it would fit perfectly to the screen size.

If you don't want a full-screen dialog, how big do you want your dialog boxes to be? You could always resize the boxes after creation to a percentage of the screen width and height, using the resize function and qApp->desktop() to get the screen size.

You shouldn't have to make a direct call to resize(sizeHint()), as that should be done automatically.

I've found that GUI creation with Qt can be really tricky, and sometimes just downright frustrating. One problem that I've found, at least with Qt 2.x, is that the default sizeHints aren't always appropriate for use on a PDA-size screen. For example, the QMultiLineEdit widget has a default height of 6 lines, unless restricted using a fixed height or setting the maximum number of visible lines. However, if you set a fixed value for the height/number of lines, the app textbox may not grow properly for other resolutions. I ran into this problem in knQuiz, and ended up having to subclass the QMultiLineEdit widget to fix it.

- ashikase
anpachi, gifu, japan
Go to the top of the page
 
+Quote Post
tumnus
post Nov 13 2004, 11:38 AM
Post #10





Group: Members
Posts: 1,176
Joined: 3-October 03
From: UK
Member No.: 547



Using QT Designer you need to have a look at the Spacer widget and the sizePolicy properties of the other widgets.

With expanding size policies and the Spacers in the appropriate places along with the layout widgets will cause widgets to grow and shrink with the form.

You should never ever use absolute widget and form sizes/positions unless there is a good reason to do so in your application.

If you want I can send you a .ui file I created with QT Designer for an app I started a while ago (and still need to get around to finishing). It resizes without any trouble and does not require any extra code whatsoever so long as it is shown with showMaximized(). As ashikase says, any form will have to be manually scaled if you do not want it to take the full screen but still take about the same percentage of the screen at different resolutions.
Go to the top of the page
 
+Quote Post
vanstrien
post Nov 14 2004, 04:55 AM
Post #11





Group: Members
Posts: 58
Joined: 22-August 03
From: Houston / London
Member No.: 374



Tumnus,

Yeah, I would appreciate that. Would you mind sending it to michael at vanstrien dot net?

I was apprehensive about running dailogs as maximised (if I understand correctly the implications of that) but since it is too much hassle to make non-fullscreen dialogs fit well then I suppose I should just do that.

Thanks for the help.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 30th July 2014 - 09:22 PM