Skip to content
Snippets Groups Projects
Commit b32681d8 authored by Pouchet Pierre's avatar Pouchet Pierre
Browse files

Ajout debugs

tentative de faire marcher la lecture de la liste de mots et de l'image, mais ça ne marche toujours pas
parent d9a7a651
No related branches found
No related tags found
No related merge requests found
......@@ -15,14 +15,21 @@ qt_add_executable(appMotus
qt_add_qml_module(appMotus
URI Motus
VERSION 1.0
QML_FILES
Main.qml
RESOURCES Ressources.qrc
QML_FILES Case.qml
QML_FILES Key.qml
QML_FILES BackKey.qml
QML_FILES Bouton.qml
SOURCES wordchooser.h wordchooser.cpp
Case.qml
Key.qml
BackKey.qml
Bouton.qml
Choosebutton.qml
SOURCES
wordchooser.h
wordchooser.cpp
RESOURCES
Ressources.qrc
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
......
import QtQuick
import QtQuick.Controls 2.15
Item {
property alias buttonText: button.text
width: 300
height: 200
Rectangle {
id: rectangle
x: 0
y: 0
width: 300
height: 200
color: "#ffffff"
Button {
id: button
x: 2
y: 0
width: 298
height: 200
text: qsTr("Bouton")
}
}
}
......@@ -57,6 +57,27 @@ Window {
}
}
Choosebutton {
id: choosebutton
x: 663
y: 249
buttonText: "Générer un mot"
MouseArea {
id: mouseArea1
x: 0
y: 0
width: 400
height: 200
onClicked: {
let mot = wordChooser.getRandomWord();
console.log("Mot choisi :", mot);
case3._textText = mot;
onClicked: case3._textColor="#51c3e1";
}
}
Image {
id: testImage
......@@ -390,6 +411,8 @@ Window {
}
}
Keys.onPressed: (event) => {
if (event.key === Qt.Key_A) {
case1._textText = qsTr("C");
......@@ -399,3 +422,4 @@ Window {
}
}
}
}
......@@ -6,5 +6,6 @@
<file>Key.qml</file>
<file>words_alpha.txt</file>
<file>back_key.png</file>
<file>Choosebutton.qml</file>
</qresource>
</RCC>
......@@ -2,14 +2,17 @@
#include <QFile>
#include <QTextStream>
#include <QRandomGenerator>
QFile file("words_alpha.txt");
#include <QDebug>
WordChooser::WordChooser(QObject *parent) : QObject(parent) {
loadWords();
}
void WordChooser::loadWords() {
QFile file("qrc:/words_alpha.txt");
QFile file(":/words_alpha.txt"); // ✅ fonctionne avec le .qrc
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&file);
while (!in.atEnd()) {
......@@ -18,13 +21,20 @@ void WordChooser::loadWords() {
words.append(line);
}
file.close();
qDebug() << "✅ Mots chargés :" << words.size();
} else {
qDebug() << "❌ Erreur : impossible d'ouvrir words_alpha.txt";
}
}
QString WordChooser::getRandomWord() {
if (words.isEmpty())
if (words.isEmpty()) {
qDebug() << "❌ Aucune donnée chargée dans words.";
return "";
}
int index = QRandomGenerator::global()->bounded(words.size());
return words[index];
QString mot = words[index];
qDebug() << "✅ Mot choisi :" << mot;
return mot;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment