无法在Qt 5.11中更改QuickStyle

时间:2018-06-13 16:04:51

标签: qt styles

嘿我正在使用Qt Creator,因为在visual studio中还没有qml实现。

无论如何,我都无法改变快速组件的风格。我已尝试使用全局常量和C ++ API调用,但它仍然会抛出错误。我不知道还有什么可以尝试。

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtQuickControls2/QQuickStyle>

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);

    QQuickStyle::setStyle(QLatin1String("Material"));

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}

我停下来,我得到了这些错误:

main.qml:6: error: Expected token `{'

main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl QQuickStyle::setStyle(class QString const &)" (__imp_?setStyle@QQuickStyle@@SAXAEBVQString@@@Z) referenced in function main

debug\RandomGenerator.exe:-1: error: LNK1120: 1 unresolved externals

我不知道该怎么做,没有更多的教程解释这一点。

1 个答案:

答案 0 :(得分:0)

您可以尝试在qml中执行此操作。

qtquickcontrols2.conf

中输入
#observables: []


#relations: array:1 [▼
    "user" => Client {#769 ▼
      #fillable: array:14 [▶]
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:17 [▼
        "id" => 1
        "title" => "مشتری اول"
        "description" => "مشتری اول"
        "fax" => 123
        "adrress1" => "مشتری اول"
        "adrress2" => null
        "adrress3" => null
        "adrress4" => null
        "adrress5" => null
        "telephone1" => 123
        "telephone2" => null
        "telephone3" => null
        "telephone4" => null
        "telephone5" => null
        "client_type" => null
        "created_at" => null
        "updated_at" => null

如果要更改颜色或其他属性,请在 AplicationWindow

main.qml 中输入
[Controls]
Style=Material

[Material]
Theme=Dark

有关样式和属性的更多信息,您可以找到here

相关问题