IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Qt Quick Discussion :

Erreur sur Android : can't find surface 1


Sujet :

Qt Quick

  1. #1
    Membre du Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Janvier 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 62
    Points : 54
    Points
    54
    Par défaut Erreur sur Android : can't find surface 1
    Bonjour,

    Je suis en train de développer une appli sous Qt5.4 pour android et autres.

    Sous Windows en test tout fonctionne bien mais sous android sur samsung Galaxy S3 4.4 j'ai un message d'erreur lors du clique sur un bouton :

    W/libTest.so(21229): (null):0 ((null)): Can't find surface 1
    L'appli est compilé avec SDK android-21 j'ai testé avec le dernier SDK android-22 idem.

    Code du bouton :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    import QtQuick 2.4
    import QtQuick.Window 2.2
     
    Window {
        visible: true
        MainForm {
            anchors.fill: parent
            button1.onClicked{
     
                var component = Qt.createComponent("Menu.qml");
                component.createObject();
     
     
     
            }
     
            Component.onCompleted: SqlSyncDB
        }
     
    }
    Quelqu'un aurait-il une petite idée ?


    Merci d'avance.

    Sl@ke

  2. #2
    Rédacteur/Modérateur

    Avatar de Jiyuu
    Homme Profil pro
    Développeur amateur
    Inscrit en
    Janvier 2007
    Messages
    2 456
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur amateur
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 2 456
    Points : 6 789
    Points
    6 789
    Billets dans le blog
    15
    Par défaut


    Pourrais-tu nous donner un peu plus de code ?

    À quoi correspondent button1 et SqlSyncDB ? (comment sont-ils présentés dans ton code ?)

    @+

    J
    Initiation à Qt Quick et QML : Partie 1 - Partie 2
    En cas de besoin, pensez à la
    Mon site et mes tutoriaux sur Developpez.com
    Pas de question technique par MP... Les forums sont là pour ça

  3. #3
    Membre du Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Janvier 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 62
    Points : 54
    Points
    54
    Par défaut
    Salut,

    le bouton me charge une autre fenêtre un truc tous bête avec des images qui serviront de boutons. Qand je clique sur bouton 1 menu doit ce charger
    SqlSyncDB est une syncro de DB pas encore finit:

    voici quelque bout de code :
    main.cpp
    Code C++ : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
        ItemModel model;
        model.addItem(ChargeList("toto","titi"));
     
        SqlSyncDB SqlSyncDB;
        QQmlApplicationEngine engine;
        engine.rootContext()->setContextProperty("SqlSyncDB",&SqlSyncDB);
        engine.rootContext()->setContextProperty("ListeModel", &model);
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
     
     
        return app.exec();
    }

    SqlSyncDb
    Code C++ : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
     
    #include "sqlsyncdb.h"
     
    SqlSyncDB::SqlSyncDB()
    {
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        /*db.setHostName("db1.free-h.org");
        db.setDatabaseName("freeh_db_76598");
        db.setUserName("freeh_76598_33");
        db.setPassword("Pj92WdQr");
        if (db.open())
        {
            // Synchronisation de la DB distante sur Local
     
        }else{
            //QMessageBox::critical(this, tr("Erreur de connexion"), tr("Vérifier votres connexion internet"));
     
        }
     
        db.~QSqlDatabase();
        //QMessageBox::critical(this, tr("Erreur de connexion"), tr("Vérifier votres connexion internet"));
    */
    }
    MainForm.ui.qml
    Code qml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
     
    import QtQuick 2.3
    import QtQuick.Controls 1.2
    import QtQuick.LocalStorage 2.0
     
    Rectangle {
        id: rectangle1
       // property alias mouseArea: mouseArea
        property alias button1: button1
        property alias mouseArea1: mouseArea1
     
        Text {
            id: txt
            anchors.centerIn: parent
            text: "Hello World"
        }
     
        Button {
            id: button1
            x: 129
            y: 97
            text: qsTr("Button")
     
     
            checkable: false
            anchors.horizontalCenterOffset: -39
            anchors.horizontalCenter: parent.horizontalCenter
        }
     
        MouseArea {
            id: mouseArea1
            x: -77
            y: 97
            width: 75
            height: 23
        }
     
     
    }
    Main.qml
    Code qml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    import QtQuick 2.4
    import QtQuick.Window 2.2
     
    Window {
        visible: true
        MainForm {
            anchors.fill: parent
            button1.onClicked{
     
                var component = Qt.createComponent("Menu.qml");
                component.createObject();
     
     
     
            }
     
            Component.onCompleted: SqlSyncDB
        }
     
    }

    Menu.qml
    Code qml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
     
    import QtQuick 2.4
    import QtQuick.Window 2.2
     
    Window {
        visible : true
        id: mainMenu
        //property alias step: step()
     
        MenuForm{
            anchors.fill: parent
     
            //positionnement des fenêtres
            banniere.width: mainMenu.width*0.85
            banniere.height: mainMenu.height*0.1
     
            iconeListe.width: mainMenu.width*0.2
            mouseAeraListe.width: mainMenu.width*0.2
            iconeListe.height: mainMenu.width*0.2
            mouseAeraListe.height: mainMenu.width*0.2
            iconeListe.anchors.leftMargin: mainMenu.width*0.1
            iconeListe.anchors.topMargin: mainMenu.height*0.1
     
            iconeSignet.width: mainMenu.width*0.2
            mouseAeraSignet.width: mainMenu.width*0.2
            iconeSignet.height: mainMenu.width*0.2
            mouseAeraSignet.height: mainMenu.width*0.2
            iconeSignet.anchors.leftMargin: mainMenu.width*0.1
            iconeSignet.anchors.topMargin: mainMenu.height*0.1
     
            iconeNew.width: mainMenu.width*0.2
            mouseAeraNew.width: mainMenu.width*0.2
            iconeNew.height: mainMenu.width*0.2
            mouseAeraNew.height: mainMenu.width*0.2
            iconeNew.anchors.leftMargin: mainMenu.width*0.1
            iconeNew.anchors.topMargin: mainMenu.height*0.1
     
            iconeCat.width: mainMenu.width*0.2
            mouseAeraCat.width: mainMenu.width*0.2
            iconeCat.height: mainMenu.width*0.2
            mouseAeraCat.height: mainMenu.width*0.2
            iconeCat.anchors.leftMargin: mainMenu.width*0.045
            iconeCat.anchors.topMargin: mainMenu.height*0.1
     
            iconeRech.width: mainMenu.width*0.2
            mouseAeraRech.width: mainMenu.width*0.2
            iconeRech.height: mainMenu.width*0.2
            mouseAeraRech.height: mainMenu.width*0.2
            iconeRech.anchors.leftMargin: mainMenu.width*0.045
            iconeRech.anchors.topMargin: mainMenu.height*0.1
     
            iconeParam.width: mainMenu.width*0.2
            mouseAeraParam.width: mainMenu.width*0.2
            iconeParam.height: mainMenu.width*0.2
            mouseAeraParam.height: mainMenu.width*0.2
            iconeParam.anchors.leftMargin: mainMenu.width*0.045
            iconeParam.anchors.topMargin: mainMenu.height*0.1
     
            iconeSync.width: mainMenu.width*0.2
            mouseAeraSync.width: mainMenu.width*0.2
            iconeSync.height: mainMenu.width*0.2
            mouseAeraSync.height: mainMenu.width*0.2
            iconeSync.anchors.leftMargin: mainMenu.width*0.045
            iconeSync.anchors.topMargin: mainMenu.height*0.1
     
     
     
            mouseAeraListe.onClicked:{
                var component
                component = Qt.createComponent("Liste.qml")
                component.createObject()
            }
        }
    }
    Menu.ui.qml
    Code qml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
     
    import QtQuick 2.4
    import QtQuick.Controls 1.2
    import QtQuick.LocalStorage 2.0
    import QtPositioning 5.4
     
     
    Rectangle {
        property alias mouseAeraListe: mouseAreaListe
        property alias mouseAeraSignet: mouseAreaSignet
        property alias mouseAeraNew: mouseAreaNew
        property alias mouseAeraCat: mouseAreaCat
        property alias mouseAeraRech: mouseAreaRech
        property alias mouseAeraParam: mouseAreaParam
        property alias mouseAeraSync: mouseAreaSync
        property alias banniere:banniere
        property alias iconeListe: iconeListe
        property alias iconeSignet: iconeSignet
        property alias iconeNew: iconeNew
        property alias iconeCat: iconeCat
        property alias iconeRech: iconeRech
        property alias iconeParam: iconeParam
        property alias iconeSync: iconeSync
     
        id: rectangle1
        width: 330
        height: 330
        color: "#a3b0db"
     
     
        Rectangle {
                id: banniere
                x: 8
                y: 8
                //width: 362
                height: 44
                color: "#ef8f8f"
                anchors.horizontalCenter: parent.horizontalCenter
            }
     
                Image {
                    id: iconeListe
                    width: 39
                    height: 39
                    anchors.top: banniere.bottom
                    anchors.topMargin: 17
                    anchors.left: parent.left
                    anchors.leftMargin: 44
                    fillMode: Image.PreserveAspectFit
                    source: "Liste.png"
     
                    MouseArea {
                        id: mouseAreaListe
                        x: 0
                        y: 0
                        width: 39
                        height: 38
                        opacity: 1
                        hoverEnabled: true
     
                    }
                }
     
                Image {
                    id: iconeNew
                    width: 38
                    height: 38
                    anchors.top: banniere.bottom
                    anchors.topMargin: 17
                    anchors.left: iconeSignet.right
                    anchors.leftMargin: 0
                    source: "Nouveau.png"
     
                    MouseArea {
                        id: mouseAreaNew
                        anchors.fill: parent
                        hoverEnabled: true
                    }
                }
     
                Image {
                    id: iconeSignet
                    x: 83
                    width: 39
                    height: 38
                    anchors.top: banniere.bottom
                    anchors.topMargin: 17
                    anchors.left: iconeListe.right
                    anchors.leftMargin: 0
                    source: "signets.png"
     
                    MouseArea {
                        id: mouseAreaSignet
                        anchors.fill: parent
                        hoverEnabled: true
                    }
                }
     
                Image {
                    id: iconeRech
                    width: 39
                    height: 38
                    anchors.top: iconeListe.bottom
                    anchors.topMargin: 46
                    anchors.left: iconeCat.right
                    anchors.leftMargin: 0
                    source: "recherche.png"
     
                    MouseArea {
                        id: mouseAreaRech
                        anchors.fill: parent
                        hoverEnabled: true
                    }
                }
     
                Image {
                    id: iconeParam
                    width: 39
                    height: 38
                    anchors.top: iconeSignet.bottom
                    anchors.topMargin: 47
                    anchors.left: iconeRech.right
                    anchors.leftMargin: 0
                    source: "parametres.png"
     
                    MouseArea {
                        id: mouseAreaParam
                        anchors.fill: parent
                        hoverEnabled: true
                    }
                }
     
                Image {
                    id: iconeSync
                    width: 39
                    height: 38
                    anchors.top: iconeNew.bottom
                    anchors.topMargin: 47
                    anchors.left: iconeParam.right
                    anchors.leftMargin: 0
                    source: "Synchro.png"
     
                    MouseArea {
                        id: mouseAreaSync
                        anchors.fill: parent
                        hoverEnabled: true
                    }
                }
     
                Image {
                    id: iconeCat
                    width: 39
                    height: 38
                    anchors.left: parent.left
                    anchors.leftMargin: 23
                    anchors.top: iconeListe.bottom
                    anchors.topMargin: 46
                    source: "categorie.png"
     
                    MouseArea {
                        id: mouseAreaCat
                        x: 78
                        y: -58
                        anchors.fill: parent
                        hoverEnabled: true
                    }
                }
    }


    Merci

  4. #4
    Membre du Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Janvier 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 62
    Points : 54
    Points
    54
    Par défaut
    Hello,

    Voilà j'avance il fallait que j'utilise StackView et la sous android ça fonctionne

    Seul problème, si on peut me donner des indices, je voudrais accéder à l'id de mon stackView de mon main.qml depuis mon fichier Menu.qml.


    Merci

  5. #5
    Rédacteur/Modérateur

    Avatar de Jiyuu
    Homme Profil pro
    Développeur amateur
    Inscrit en
    Janvier 2007
    Messages
    2 456
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur amateur
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 2 456
    Points : 6 789
    Points
    6 789
    Billets dans le blog
    15
    Par défaut


    Content que tu es pu régler une partie de ton souci.

    Concernant ta question sur l'obtention de l'id de ton StackView s'il fait parti de ton main.qml et que ton Menu.qml en fait aussi parti tu devrais y avoir accès directement non ? Mais peut-être que le fait de créer ton Menu.qml au clic d'un bouton bloc ceci...
    Si c'est ça, tu peux peut-être envisager de passer par l'objectName de ton composant et le retrouver depuis ton code (C++ ou Python).

    Sur mon deuxième tuto je montre comment faire cela, mais par contre c'est du Python... et là je suis pas encore assez calé en C++ pour te donner une bonne solution.


    Bonne continuation.

    ++

    J
    Initiation à Qt Quick et QML : Partie 1 - Partie 2
    En cas de besoin, pensez à la
    Mon site et mes tutoriaux sur Developpez.com
    Pas de question technique par MP... Les forums sont là pour ça

  6. #6
    Membre du Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Janvier 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 62
    Points : 54
    Points
    54
    Par défaut
    Salut et merci pour ta réponse,

    Concernant ta question sur l'obtention de l'id de ton StackView s'il fait parti de ton main.qml et que ton Menu.qml en fait aussi parti tu devrais y avoir accès directement non ?
    Justement ça ne fonctionne pas peut être une erreur dans mon main.qml ou peut être le faite que j'utilise des ui.qml

    Voici mon main modifié

    Code qml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
     
    Window {
        visible: true;
        id:root;
     
        StackView{
            id:stackView;
            anchors.fill: parent;
        }
        Component{
            id:main;
            MainForm {
                button1.onClicked{
                    stackView.push(Qt.resolvedUrl("Menu.qml"))
                }
                Component.onCompleted: SqlSyncDB
            }
        }
     
     
        Component.onCompleted: stackView.push(main)
     
    }
    et mon mainForm.ui.qml

    Code qml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
     
    import QtQuick 2.3
    import QtQuick.Controls 1.2
    import QtQuick.LocalStorage 2.0
     
    Rectangle {
        id: rectangle1
        property alias button1: button1
     
        Text {
            id: txt
            anchors.centerIn: parent
            text: "Hello World"
        }
     
        Button {
            id: button1
            x: 129
            y: 97
            text: qsTr("Button")
            checkable: false
            anchors.horizontalCenterOffset: -39
            anchors.horizontalCenter: parent.horizontalCenter
        }
     
     
    }


    Merci
    ++

  7. #7
    Membre du Club
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Janvier 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Technicien maintenance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 62
    Points : 54
    Points
    54
    Par défaut
    Hello,

    donc c'est ok tout fonctionne bien

    Petit erreur de ma part

    Merci pour l'aide

  8. #8
    Rédacteur/Modérateur

    Avatar de Jiyuu
    Homme Profil pro
    Développeur amateur
    Inscrit en
    Janvier 2007
    Messages
    2 456
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur amateur
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 2 456
    Points : 6 789
    Points
    6 789
    Billets dans le blog
    15
    Par défaut


    Content pour toi. N'hésite pas à donner la solution ou nous expliquer quelle était ton erreur. Qui sait, ça pourrait servir à d'autre.

    Et n'oublie pas le bouton
    Initiation à Qt Quick et QML : Partie 1 - Partie 2
    En cas de besoin, pensez à la
    Mon site et mes tutoriaux sur Developpez.com
    Pas de question technique par MP... Les forums sont là pour ça

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2003] Erreur "can't find project or library" sur la fonction Environ
    Par Chakalaka dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 17/01/2013, 21h21
  2. erreur sur un find
    Par zandru dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 01/04/2009, 15h41
  3. [Dev-Pascal] Erreur "can't find unit"
    Par darkpleguis dans le forum Autres IDE
    Réponses: 4
    Dernier message: 01/10/2007, 20h47
  4. Réponses: 5
    Dernier message: 08/08/2007, 16h51
  5. [Débutant] Erreur "can't find unit Messages"
    Par Gargoyle dans le forum Pascal
    Réponses: 6
    Dernier message: 07/04/2007, 00h49

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo