Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]how can i include a class in a dialog?
QtWS25 Last Chance

[solved]how can i include a class in a dialog?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rh
    wrote on last edited by
    #1

    hello again.
    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
    ../signup.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
    ../signup.h
    FORMS += dialog.ui
    ../signup.ui
    INCLUDEPATH += ../@

    if someone knows the answer please help me.
    thank you.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      It looks like your include path is wrong. The compiler complains that the include file "../Users.h" is not found.

      [quote author="r@h@" date="1310232491"]
      @
      #include "signup.h"
      #include "ui_signup.h"
      #include "source/src/User.h"
      @
      [/quote]

      This include section would look a bit more logical based on the information of your .pro file.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rh
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          I just want to make you aware of on option to store such information user names and related information into a file. "QSettings ":http://doc.qt.nokia.com/4.7/qsettings.html 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.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved