Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Label is not a Type (only with 5.12)



  • Hi.
    In my app, I load this piece of qml inside a QQuickView. It works fine on all platforms and versions, but Qt 5.12 for iOS.

    Only on Qt 5.12 for iOS I get the error "Ctrls.Label is not a type"

    Does somebody have any idea how and where to debug?

    import QtQuick 2.12
    import QtQuick.Controls 2.5 as Ctrls
    
    Rectangle {
        id: window
        visible: true
    
        Column {
            spacing: 2
            width: parent.width
    
            Ctrls.Label {
                width: parent.width
                wrapMode: Label.Wrap
                height: implicitHeight
                horizontalAlignment: Qt.AlignHCenter
                text: "This is just a Label."
            }
        }
    }
    
    


  • The problem is solved by adding this line of code in the main() :
    QQuickStyle::setStyle("Fusion");

    main.cpp

    
    int main(int argc, char *argv[])
    {
       QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
       QApplication app(argc, argv); 
       QQuickStyle::setStyle("Fusion");
    
    ...
    
    }
    

  • Qt Champions 2018

    I tried on your issue.
    However, My environment is Ubuntu 16.04 LTS x64 (linux) / Qt 5.12 :(
    Unfortunately, I don't have iOS develop environment....

    It isn't iOS, but it was able to execute normally.
    0_1545985291061_Screenshot from 2018-12-28 16-56-52.png

    import QtQuick.Controls 2.5 as Ctrls
    

    As far as I see Qt document, I think that QtQuick.Controls version is correct at 5.12.
    http://doc.qt.io/qt-5/qtquickcontrols-index.html#versions

    import QtQuick.Controls 2.12 as Ctrls
    

    0_1545985337352_QtQuick.png

    Please confirm it.



  • @KazuoAsano

    Thank you very much for replying. You are right, should be QtQuick.Controls 2.12.

    I tried the code on another project and it works fine. So, the problem is only on my main project. It looks like is not including the necessary components in the bundle deployed to the device.

    But I have no idea where to look for such an issue.


  • Lifetime Qt Champion

    Hi,

    Compare your projects .pro file for any difference in the modules used for example.


  • Qt Champions 2018

    @JoZCaVaLLo ,
    thk reply @SGaist, and my others solution.

    For iOS, I think that the necessary modules will be automatically deployed for iOS.
    If QML module error occurs in iOS, it may be improved by distclean and deploy,again.
    In Android case, I could improved similarity issue.



  • The problem is solved by adding this line of code in the main() :
    QQuickStyle::setStyle("Fusion");

    main.cpp

    
    int main(int argc, char *argv[])
    {
       QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
       QApplication app(argc, argv); 
       QQuickStyle::setStyle("Fusion");
    
    ...
    
    }
    

Log in to reply