zoukankan      html  css  js  c++  java
  • QML出现error: Expected token `numeric literal'

    简单地在界面上画了两个Rectangle,运行出来,提示

    H:1_helloQtQuickmain0.qml:114: error: Expected token `numeric literal'

    最后发现:main.cpp中设置source时路径写错,应当有三个“/”,而不是两个: viewer.setSource(QUrl("qrc:///main.qml"));

    //main.cpp
    
    #include <QGuiApplication>
    #include <QQuickView>
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
        QQuickView viewer;
        viewer.setResizeMode(QQuickView::SizeRootObjectToView);
        viewer.setSource(QUrl("qrc:///main.qml"));//正确的是三个
        viewer.show();
    
        return app.exec();
    }
    //main.qml
    
    import QtQuick 2.0
    import QtQuick.Window 2.12
    
    Rectangle {
        600;
       height: 400;
    
       Rectangle {
           id: rect1;
            200;
           height: 100;
           anchors.top: parent.top;
           anchors.topMargin: 20;
           anchors.left: parent.left;
           anchors.leftMargin: 20;
           gradient: Gradient {
               GradientStop {position: 0.0; color: "red"}
               GradientStop {position: 0.5; color: "blue"}
           }
       }
    
       Rectangle {
            id: rect2;
             200;
            height: 100;
            anchors.top: rect1.top;
            anchors.left: rect1.right;
            anchors.leftMargin: 20;
            rotation: 90;
            gradient: Gradient {
                GradientStop {position: 0.0; color: "black"}
                GradientStop {position: 0.5; color: "blue"}
            }
       }
    
    }


  • 相关阅读:
    树状数组
    POJ 1178 -- 国王和骑士
    read
    优先队列
    统计八连块
    1579、Function Run Fun(记忆化搜索)
    5488: 石子归并II (区间DP+环形DP+四边形不等式优化)
    4797: 能量项链(区间DP,环形DP)
    5936 桃子的矩阵快速幂
    Happy Necklace(找规律+矩阵快速幂)
  • 原文地址:https://www.cnblogs.com/BASE64/p/14469091.html
Copyright © 2011-2022 走看看