PDA

View Full Version : Shape-changing dialog group box not properly sized



qzoltan
5th April 2018, 11:45
Hi all,

I am new in Qt programming and I use Linux/KDE4/Qt 4.8.7 + Qt creator 2.8.0 + Qt Designer.
Since I am new to QT I am trying to learn it from the C++-GUI-Programming-with-Qt-4-1st-ed.pdf - GUI-Programming-with-Qt-4-1st-ed.pdf (https://github.com/rascheel/coms229-project2/blob/master/docs/C%2B%2B-GUI-Programming-with-Qt-4-1st-ed.pdf)

There is an example code for a simple ui based Dynamic dialog. The Ui is created in Designer and coded in Qt Creator (with qmake compile for ui). All works ok except that the window is not properly formatted. This is how it looks like:
12804

The code is simple - sortdialog.ui, sortdialog.h, sortdialog.cpp, main.cpp
12805
12806
12807
12808

I am not sure why the dialog size is deformed. When I hit "More" button it looks ok.

Can anybody help please?

Thanks

d_stranz
5th April 2018, 16:38
The UI file hard-codes the initial geometry to a size 256 x 306 pixels. What is probably happening is that your system has a larger font size or scale than that used by the book's author, so the widgets that contain text get clipped. When you click the "More" button and the widget expands dynamically, the dialog then automatically adjusts its size so everything fits. I think if you manually adjust the size of the dialog by grabbing the size handle (before clicking "More") you can get it to look normal.

Open the UI file in Qt Designer and resize the dialog until everything fits, then save and rebuild. Then the dialog should look as you expect.

qzoltan
10th April 2018, 09:46
Thanks for the help. This solved the issue. Another issue I had is that the resulting ui_sortdialog.h is not updated when I perform clean all/rebuild from the Qt Crator API. I need to perform qmake/make all the time from the command line.
Anyway the size issue was fixed by Qt Designer resize / rebuild. Thanks again.