[solved]how can i include a class in a dialog?
in my program what shoudl i do if i want to include an object class(User class in here) that i myself define it ,
and then use that class in one of functions (on_cmdOk_clicked() )of my dialog(Signup in here)?
i try these code:
- #include "signup.h"
- #include "ui_signup.h"
- #include "../User.h"
- void Signup::on_cmdOk_clicked()
- QString UserName=ui->UserName->text();
- QString PassWord=ui->PassWord->text();
- QString FirstName=ui->FirstName->text();
- QString LastName=ui->LastName->text();
- Users users;
- users.insert(UserName,PassWord,FirstName,LastName,int id=-1);
but i recieve below error:
..\signup.cpp:3:21: error: ../User.h: No such file or directory
..\signup.cpp: In member function ‘void Signup::on_cmdOk_clicked()’:
..\signup.cpp:36: error: ‘Users’ was not declared in this scope
..\signup.cpp:36: error: expected ‘;’ before ‘users’
..\signup.cpp:37: error: ‘users’ was not declared in this scope
..\signup.cpp:37: error: expected primary-expression before ‘int’
and this is my .pro file:
- TARGET = NoteBook
- TEMPLATE = app
- SOURCES += dialog.cpp \
- ../source/src/main.cpp \
- HEADERS += dialog.h \
- ../source/src/User.h \
- ../source/src/TagRelation.h \
- ../source/src/Tag.h \
- ../source/src/header.h \
- ../source/src/Content.h \
- ../source/src/BaseRelation.h \
- ../source/src/BaseIndex.h \
- ../source/src/BaseEntity.h \
- FORMS += dialog.ui \
- INCLUDEPATH += ../
if someone knows the answer please help me.
yeah .you’re right.
it works now properly.
thank you to reply and help me.
in my User class there is a file that save information of users.
if i want to insert a new user in (on_cmdOk_clicked()) function,can i get an object from User class in main.cpp and use that object and it’s functions (like insert) in the above function of Signup.cpp(Signup is a dialog in my program)?
because if i want to get an object of User class in that function (on_cmdOk_clicked()) ,whenever that ok button be pushed ,an object of User class and then a file iwill be create and it’s not true.
can you help me in this topic too?
I just want to make you aware of on option to store such information user names and related information into a file. QSettings [doc.qt.nokia.com] Typically QSettins facilitates that quite nicely for different applications and platforms. On windows you have the option to store in ini-files and also for linux the data are more easily maintained compared to hand-knitted files. You may use the file structure behind the scenes and open it from any place in your program. Maybe that would be of help.
I cannot answer your quite detailed question above. main.cpp is just a name of a file which presumably holds most or all information of your code. It all depends on what you are trying to achieve and how your program is setup. I guess it is somehow possible, but there is no way to provide details without knowing more. Anyhow, I think it would be good if you have a look to the possibilities of QSettings.