1
votes

I'm deploying my application with Qt Framework. The behaviour of layout is equal in Windows and Linux; and if I resize the windows the layout adapts. This doesn't happen in Mac OS. To develop for Mac, I'm using a virtual machine (the resolution is 1024x768), but, when I try to start my bundle in a "true" Mac (resolution's biggest) the result is terrible!

I put some pictures:

MAC - virtual machine (1024x768) - First tab (OK)

MAC - virtual machine (1024x768) - First tab (OK)

MAC - virtual machine (1024x768) - Second tab (Not OK)**

MAC - virtual machine (1024x768) - Second tab (Not OK)

**The second tab "Rubrica Contatti" is designed like the first tab "Ricettario". In designer the second tab seems ok, at runtime no!

I have tried to create a new project for test. I've set the Central Widget with Form Layout. I've created 2 Widgets that contain these items (each widget has a Grid Layout):

  • LineEdit
  • ComboBox
  • GroupBox (with Grid Layout) containing 2 labels and 2 checkboxes

All these three items are clustered in vertical layout. I put the left widget in QSizePolicy::Minimum and the right one in QSizePolicy::Preferred. In Qt Designer the left panel is smaller and the right one is horizontally enlarged. When I start the app, both widget have the same width and are in the center of the window.

Note:
When I open any project, I get this text in "General Messages" .

Warnings while parsing QML type information of /Users/denny/Qt/5.5/clang_64/qml:  
<dump of /Users/denny/Qt/5.5/clang_64/qml>:1:24: Reading only version 1.1 parts.  
<dump of /Users/denny/Qt/5.5/clang_64/qml>:10:5: Expected only Component and ModuleApi objects definitions. 

Could it be the cause?

3
Please describe the issue instead of just referring to the pictures, such as: The width didn't fill up as expected or the buttons are half the size they should be, etc. If it is a problem with not filling the area, you need to set the layout. doc.qt.io/qt-5/layout.html - phyatt
Sorry... I've set the layout from qt designer. In fact, on Windows and Linux the area is filled - Denny Vavalà
@DennyVavalà what do you expect? Show the second tab as it should be. Are you using horizontal spacer items? - UmNyobe
In my comment there are links to other pictures... [Linux (1366x768) - Second Tab "Rubrica Contatti"] (i.stack.imgur.com/C9M3Q.png) <--- This is correct . No, I use form and grid layout - Denny Vavalà

3 Answers

2
votes

The problem remains, but it solved so (for now)...

QApplication::setStyle("fusion");  

My app won't use Mac Themes, but it will use Fusion Theme...

Note:
The graphic is uglier, but it works!

0
votes
  • For the panel on the left, set the horizontal size policies to QSizePolicy::Minimum. It means this widget can be larger but there is no point expanding it.
  • For the panel on the right, set the horizontal size policies to QSizePolicy::Preferred. It means if there is space to grow further use it.

Put the left panel widget in a single widget, the right panel widgets in another widget, and use a form layout. The form layout usually set the right size policies for left and right.

0
votes

It happens because, different styles use different expanding policies. For example the QFormLayout deals with enum QFormLayout::FieldGrowthPolicy.

QFormLayout::FieldsStayAtSizeHint - This is the default for QMacStyle.

QFormLayout::AllNonFixedFieldsGrow - This is the default policy for most styles.

QFormLayout::ExpandingFieldsGrow - This is the default policy for Plastique.