[SOLVED] Mac OSX 'basiclayouts' example behaving differently than Windows version
-
New to Qt, and trying to work through examples to verify the cross platform capability to determine if our company's next project would benefit from this.
Found a discrepancy between Mac OSX and Windows....the basiclayouts example place a QFormLayout on the main window. On Windows 7 system the dialog initialize and stretch the QFormLayout to view width, and then resize the layout correctly when resizing the window. On Mac OSX it does not perform the same way. It initialize to some fixed width and center in the view, then on view resize it keeps the same width and only moves the QFormLayout to stay in center without trying to resize.
I tried to fix with size policy (didn't work), also tried a containing widget with QVBoxLayout (didn't work either).
How can this example code be adapted to make the Mac version resize similar to the Windows version? -
Hi,
QFormLayout
respects the platform defaults.
Windows and OSX define different default values and criteria for Form Layout.As a general rule Qt uses defaults values for layouts and other things (like the order of buttons in standard dialogs, standard icons, ...) coming from the Platform where the application is executed. In this way the application will be better integrated in the environment where runs.
Anyway you can always force these settings to the values you need.
If you can't specify unique values for different platforms you can always (but only if is really needed) use
#ifdef
statement based on the platform like:#ifdef Q_OS_WIN // Windows specific #elif Q_OS_DARWIN // OSX #elif Q_OS_LINUX // Linux #endif
-
Hi,
QFormLayout
respects the platform defaults.
Windows and OSX define different default values and criteria for Form Layout.As a general rule Qt uses defaults values for layouts and other things (like the order of buttons in standard dialogs, standard icons, ...) coming from the Platform where the application is executed. In this way the application will be better integrated in the environment where runs.
Anyway you can always force these settings to the values you need.
If you can't specify unique values for different platforms you can always (but only if is really needed) use
#ifdef
statement based on the platform like:#ifdef Q_OS_WIN // Windows specific #elif Q_OS_DARWIN // OSX #elif Q_OS_LINUX // Linux #endif
@mcosta Thank you for the quick reply
How would one force the default settings....recompile Qt from source?
Regarding your #ifdef suggestion, does this mean for Mac I should rather use grid view and manually build a view that resembles the Windows version of QFormView? -
Hi,
you can change the settings for a
QFormLayout
using the propertiesfieldGrowthPolicy
,formAlignment
,labelAlignment
(as you can read in the documentation they have different values depending of the plaftorm).If you want to override the default settings (the same values each time you use a
QFormLayout
) you can write your ownQStyle
and apply it to your application.About the
#ifdef
; I mean you could set different values for a property depending on the platform. Example#ifdef Q_OS_WIN layout-> setFormAlignment(Qt::AlignLeft| Qt::AlignTop); #else layout-> setFormAlignment(Qt::AlignRight| Qt::AlignTop); #endif
NOTE: In my experience it's better to use the platform standard values because the interface will be more familiar to the final user.
-
Hi,
you can change the settings for a
QFormLayout
using the propertiesfieldGrowthPolicy
,formAlignment
,labelAlignment
(as you can read in the documentation they have different values depending of the plaftorm).If you want to override the default settings (the same values each time you use a
QFormLayout
) you can write your ownQStyle
and apply it to your application.About the
#ifdef
; I mean you could set different values for a property depending on the platform. Example#ifdef Q_OS_WIN layout-> setFormAlignment(Qt::AlignLeft| Qt::AlignTop); #else layout-> setFormAlignment(Qt::AlignRight| Qt::AlignTop); #endif
NOTE: In my experience it's better to use the platform standard values because the interface will be more familiar to the final user.
@mcosta Thank you!
The magic happened with
layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); -
@mcosta Thank you!
The magic happened with
layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); -
Hi,
If I may add
Q_OS_OSX
is the define to use when doing Max OS X specific stuff