-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestinterface.cpp
More file actions
51 lines (40 loc) · 1.51 KB
/
testinterface.cpp
File metadata and controls
51 lines (40 loc) · 1.51 KB
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
#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QVBoxLayout>
#include <QGraphicsDropShadowEffect>
class CharacterWindow : public QWidget {
public:
CharacterWindow(QWidget *parent = nullptr) : QWidget(parent) {
// Création des widgets
characterLabel = new QLabel(this);
dialogueLabel = new QLabel(this);
dialogueLabel->setWordWrap(true);
// Ajout d'une ombre à la bulle de dialogue
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this);
effect->setBlurRadius(10);
effect->setColor("#000000");
dialogueLabel->setGraphicsEffect(effect);
// Mise en page
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(characterLabel, 0, Qt::AlignHCenter);
layout->addWidget(dialogueLabel, 0, Qt::AlignHCenter);
setLayout(layout);
}
// Méthode pour afficher le personnage et le dialogue
void displayCharacterAndDialogue(const QString &characterImagePath, const QString &dialogueText) {
characterLabel->setPixmap(QPixmap(characterImagePath));
dialogueLabel->setText(dialogueText);
}
private:
QLabel *characterLabel;
QLabel *dialogueLabel;
};
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
CharacterWindow window;
window.displayCharacterAndDialogue("path/to/character.png", "Coucou voisin, ça va ?");
window.show();
return app.exec();
}
// Il faut installer la bibliothèque Qt pour interface c++