[英]Different layout between Mac and Windows/Linux (same *.ui files)
I'm deploying my application with Qt Framework. 我正在使用Qt Framework部署我的应用程序。 The behaviour of layout is equal in Windows and Linux;
在Windows和Linux中,布局的行为是相同的。 and if I resize the windows the layout adapts.
如果我调整窗口的大小,布局就会适应。 This doesn't happen in Mac OS.
在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!
要为Mac开发,我使用的是虚拟机(分辨率为1024x768),但是,当我尝试在“真正的” Mac(分辨率最大)的Mac中启动捆绑包时,结果会很糟糕!
I put some pictures: 我放了一些照片:
MAC - virtual machine (1024x768) - First tab (OK) MAC-虚拟机(1024x768)-第一个选项卡(确定)
MAC - virtual machine (1024x768) - Second tab (Not OK)** MAC-虚拟机(1024x768)-第二个选项卡(不正常)**
**The second tab "Rubrica Contatti" is designed like the first tab "Ricettario". **第二个标签“ Rubrica Contatti”的设计类似于第一个标签“ 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):
我创建了2个包含这些项目的小部件(每个小部件都有一个网格布局):
All these three items are clustered in vertical layout. 所有这三个项目都聚集在垂直布局中。 I put the left widget in QSizePolicy::Minimum and the right one in QSizePolicy::Preferred .
我将左侧小部件放在QSizePolicy :: Minimum中 ,将右侧小部件放在QSizePolicy :: Preferred中 。 In Qt Designer the left panel is smaller and the right one is horizontally enlarged.
在Qt Designer中,左侧面板较小,右侧面板水平放大。 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? 可能是原因吗?
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... 我的应用程序不会使用Mac主题,但会使用Fusion主题...
Note:
注意:
The graphic is uglier, but it works!图形比较丑陋,但是可以用!
QSizePolicy::Minimum
. QSizePolicy::Minimum
为QSizePolicy::Minimum
。 It means this widget can be larger but there is no point expanding it . QSizePolicy::Preferred
. QSizePolicy::Preferred
为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.
表单布局通常为左右设置正确的尺寸策略。
It happens because, different styles use different expanding policies. 发生这种情况是因为不同的样式使用了不同的扩展策略。 For example the QFormLayout deals with enum QFormLayout::FieldGrowthPolicy.
例如,QFormLayout处理枚举QFormLayout :: FieldGrowthPolicy。
QFormLayout::FieldsStayAtSizeHint
- This is the default for QMacStyle. QFormLayout::FieldsStayAtSizeHint
这是QMacStyle的默认设置。
QFormLayout::AllNonFixedFieldsGrow
- This is the default policy for most styles. QFormLayout::AllNonFixedFieldsGrow
这是大多数样式的默认策略。
QFormLayout::ExpandingFieldsGrow
- This is the default policy for Plastique. QFormLayout::ExpandingFieldsGrow
这是Plastique的默认策略。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.