Solved QtDeviceUtilities.DisplaySettings, QML and screen brightness
-
We have a commercial license. We are developing for Linux iMX8.
But we cannot compile for Windows under MinGW 64 (not using 32).
Code compiles and builds for the target system (Linux iMX8) and the function works. The GUI control works. All is well. Screen gets brighter, or dimmer, in response to the control.
But we are developing on Windows and the 3 lines of code tied to this are not compiling on Windows.
Any help configuring the build to work for Windows as well would be greatly appreciated.
Thanks.
-
Hi,
If these calls are system specific then use an ifdef to exclude them from other OS builds.
-
Sorry, forgot to specify, the code for setting brightness, as it is relevant to the GUI, is in QML and therefore there is no #ifdef. Though there is also no reason this should not work with Windows as well.
It is not clear from the documentation, but I am wondering if it is just QML that is crippled in this way and if it might require signaling the C++ code to set the brightness, once the user has defined a value using the QML GUI component.
-
My bad, I somehow missed the QML part.
Can you explain which compilation error you get ?
-
DisplaySettings is just not found. Could be faked with an overlay in cases where the operating system (Windows in this case) is too clueless to make it happen. Would be better than just having the build crap out when doing cross-platform development. (Yes, our target is NOT Windows and, yes, it does work on the target. But we are developing on Windows and as there is no way to conditionally compile QML it makes things difficult. Maybe QML 7?)
-
You could maybe use a
QQmlFileSelector
to include another file when developing on Windows.For example if you have a settings page with a your brightness controls you could do:
Page { //... BrightnessControls {} //... }
Move your controls with the
import QtDeviceUtilities.DisplaySettings
in this new file atqrc:/<path>/BrightnessControls.qml
Create another dummy file to be used for Windows without this import at
qrc:/<path>/+windows/BrightnessControls.qml
And then in your cpp where you have your qml engine, add an extra selector "windows" to the QQmlFileSelector of the engine:://QStringList extraSelectors; //#ifdef Q_OS_WINDOWS //extraSelectors.append("windows"): //#endif //QQmlFileSelector::::get(&engine)->setExtraSelector(extraSelectors);
EDIT: There is already a selector depending on the OS, the above code is unnecessary.
-
Won't work. Not that sort of app. And I should note that, like Windows File Explorer, the QML file selector can result in the application taking several minutes to run on Windows as it goes out looking for the availability of all network connected drives. Yes, minutes, as in centuries to a modern computer.
But I will be setting up a conditional in the project file and in the associated code to ignore Windows and just work for the target. This is far too much time wasted on something that should be a ten minute task.
-
Since you hold a commercial license do not hesitate to contact the Qt company about that matter.