如何使 QML 控件看起来默认更好?
How to make the QML controls looks default better?
我在 QtCreator 中创建了默认的 "empty" qml 应用程序。然后我只添加按钮和 运行 它:
import QtQuick 2.11
import QtQuick.Window 2.11
import QtQuick.Controls 2.4
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Button {
text: "Button1"
}
}
但是按钮看起来非常丑陋:
我应该怎么做(打开或添加或smth)让它看起来更有吸引力?
例如,即使是默认的 Win10 视图也适合我。
答案补充:
这让我很难过,但没有办法让 QtQuick 应用程序看起来比自己实现所有控制更好。下面的答案解释了如何做到这一点。
Controls 2 是一种新设计,从头开始针对性能进行了优化,它们在某种意义上背离了原生外观,朝着跨不同平台统一外观的方向发展。
您可以 select some of the additional pre-defined styles for Controls 2, or customize a style in several ways, which will easily get you a better look, alas if native look is important for you, there doesn't seem to be a shortcut to that. There was also this effort to create yet another GUI library 专门针对本机外观,但它看起来像 WIP。
请注意,您仍然可以将旧的QWidgets样式与旧的控件一起使用,但是这样做似乎需要引入widgets
模块作为项目依赖,这并不理想。
我在 QtCreator 中创建了默认的 "empty" qml 应用程序。然后我只添加按钮和 运行 它:
import QtQuick 2.11
import QtQuick.Window 2.11
import QtQuick.Controls 2.4
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Button {
text: "Button1"
}
}
但是按钮看起来非常丑陋:
我应该怎么做(打开或添加或smth)让它看起来更有吸引力?
例如,即使是默认的 Win10 视图也适合我。
答案补充: 这让我很难过,但没有办法让 QtQuick 应用程序看起来比自己实现所有控制更好。下面的答案解释了如何做到这一点。
Controls 2 是一种新设计,从头开始针对性能进行了优化,它们在某种意义上背离了原生外观,朝着跨不同平台统一外观的方向发展。
您可以 select some of the additional pre-defined styles for Controls 2, or customize a style in several ways, which will easily get you a better look, alas if native look is important for you, there doesn't seem to be a shortcut to that. There was also this effort to create yet another GUI library 专门针对本机外观,但它看起来像 WIP。
请注意,您仍然可以将旧的QWidgets样式与旧的控件一起使用,但是这样做似乎需要引入widgets
模块作为项目依赖,这并不理想。