Bon, se problème peut semblé ridicule pour certain, mais bon, pour moi ca ne l'est pas.
Voici ma classe où le problème surgit:
Je me crée un objet QString avec la string HELLO. Ensuite, je veux en retirer sa valeur std::string pour la mettre dans stdstr et par la suite l'afficher dans la console. J'ai tout tenté et j'en arrive toujours à la même erreur me disant "error: 'class QString' has no member named 'latin1'". J'ai aussi essayé la méthode ascii(), mais le même problème surgit.
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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 #ifndef ACTIONLISTENER_H_ #define ACTIONLISTENER_H_ #include <qobject.h> #include <qstring.h> #include <qtextedit.h> #include <iostream> #include <qtextstream.h> #include "../ui_gui.h" using namespace std; class ActionListener : public QObject { Q_OBJECT public: ActionListener() { } void setUI(Ui_MainWindow *ui){ form1 = ui; }; private: Ui_MainWindow *form1; public slots: void textBtnClick() { QString *str3 = new QString("HELLO"); string stdstr = str3->latin1(); cout << "Bouton text click avec valeur: " << stdstr << endl; } }; #endif /*ACTIONLISTENER_H_*/
J'utilise Qt 4.1.2.
Merci
Partager