[Interest] Qt dialogs, Ok / Cancel button order

Rutledge Shawn Shawn.Rutledge at theqtcompany.com
Mon Nov 24 10:30:20 CET 2014


On 21 Nov 2014, at 13:37, bootch at nc.rr.com wrote:

> That's disconcerting: I assumed that it would use native dialogs.

MessageDialog has a Java implementation (as native as you can get) on Android; the rest are not, because there are practically no native dialogs on Android.  So we decided not to rewrite every possible dialog in Java, because it would duplicate work that needs to be done in QML anyway; and the goal is that the QML should be portable (and styled correctly) across platforms.  If there actually were native dialogs that it didn’t require much code to use, we’d probably try to do that.

>  The documentation says QuickControls use one of: [native, QWidget, QML implemented] GUI, in that order, choosing the first 'possible'.  Where possible means something like: the platform technology allows it and someone has implemented it in Qt library?  Where at worst, it is QML implemented.
> 
> Also, I found that on a desktop, QuickControl Dialog is in a separate window, not transient (on top of) the main window, and decorated by the window manager.  See discussion at QTBUG-40568.

Dialogs in general should be separate windows, because it’s a benefit to be able to drag them out of the way, especially if they are non-modal.

“Transient for” means that the dialog window is associated with the main window: it has a hint which an X11 window manager will usually interpret to mean that the dialog should be centered over the main window.  (On some platforms Qt has to center it forcibly because there’s no way to just ask the OS to do it.)  

Unfortunately Android doesn’t support multiple windows, so we have a fallback to put the dialog’s content Item into the same scene as the application, surrounded by a fake window decoration.  If there was the concept of a separate window or dialog into which we could render OpenGL content, we’d be trying to use it.

> Has anyone documented, for all QuickControls, which are native or at least conform to platform style and HIG?  That would be nice to know in advance, so a developer could plan how much tweaking is necessary to conform.

The goal is to have all of them conform to platform style.  So far QtQuick Dialogs don’t have their own private style objects the way Controls do, but we may need to do that.  At least the individual buttons, labels, background colors etc. should be affected by the platform style.  5.4.0 is doing a lot more to make them conform to individual Android versions and variants.

I don’t think it will be a problem to fix QTBUG-42808, because Qt has been dealing with varying button order on different platforms for a long time.  Actually plain Dialog puts the cancel button on the left already, because QPlatformTheme::DialogButtonBoxLayout controls the order.  So it may turn out the bug with MessageDialog is in the Java code.




More information about the Interest mailing list