In win10 can't customization
-
Hi!
I use win 10. I don't uze style for QML. In Qt5 I can customization QtQuick.Controls, but in QT6 I get error:[08.07.2025 11:01:14.852 UTC+03:00][W]: {qrc:/qml/customWidgets/MTextField.qml:127} qrc:/qml/customWidgets/MTextField.qml:127:17: QML QQuickRectangle: The current style does not support customization of this control (property: "background" item: QQuickRectangle(0x187c27431b0, parent=0x0, geometry=0,0 0x0)). Please customize a non-native style (such as Basic, Fusion, Material, etc). For more information, see: https://doc.qt.io/qt-6/qtquickcontrols2-customize.html#customization-reference
I get error in TextField here:
background: Rectangle { id: backgroundField radius: 5 color: root.readOnly ? backgroundColorDisabled : backgroundColorPrimary border.width: ( isError || root.activeFocus ) ? 2 : 1 border.color: isError ? "red" : root.activeFocus ? themeStyles.primaryColor : "#BDBDBD" }
-
I think this is because of the default style that is used in Qt 6. I found that I needed to use the "Basic" style. In my C++ startup code, I have this:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QQuickStyle::setStyle("Basic"); #endif
I think you can set the style in other ways, such as using an environment variable, but this is how I do it.
-
-
I think this is because of the default style that is used in Qt 6. I found that I needed to use the "Basic" style. In my C++ startup code, I have this:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QQuickStyle::setStyle("Basic"); #endif
I think you can set the style in other ways, such as using an environment variable, but this is how I do it.
@Bob64 said in In win10 can't customization:
you can set the style in other ways
Yes, the best way is via the import statement:
import QtQuick.Controls.Basic
-- this allows the Qt Quick Compiler to optimize your code. That optimization can't happen if you set the style at runtime. -
@Bob64 said in In win10 can't customization:
you can set the style in other ways
Yes, the best way is via the import statement:
import QtQuick.Controls.Basic
-- this allows the Qt Quick Compiler to optimize your code. That optimization can't happen if you set the style at runtime.@JKSH said in In win10 can't customization:
Yes, the best way is via the import statement:
import QtQuick.Controls.Basic
-- this allows the Qt Quick Compiler to optimize your code. That optimization can't happen if you set the style at runtime.Thanks for this tip. I'll bear it in mind for later. I currently have my code running in both Qt 5.15 and 6.8 as I may or may not need to make the switch in the near future (out of my control unfortunately). The runtime selection is a pragmatic approach for me at the moment.