Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to create session and call it in QT
Forum Updated to NodeBB v4.3 + New Features

How to create session and call it in QT

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
18 Posts 3 Posters 4.4k Views 2 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #6

    Hi,

    So... Do you have any central database to store these details ?
    Should it be only locally ?

    You have to give details about your application.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    2
    • J Offline
      J Offline
      jiji
      wrote on last edited by
      #7

      Hi,
      I store my data base in a mongoDB server, and I want to store user details locally, because when I close the application the user disconnect, but I want it remain connected.

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #8

        Hi,

        This topic might have links to sample code you need.

        You could also search for other posts of course.

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        1
        • J Offline
          J Offline
          jiji
          wrote on last edited by
          #9

          I managed to connect mongodb with QT and I recovered the data but the problem is when I closed the application the user will disconnect by default and when I open the application always the authentication interface is displayed.
          So I want to save the user data locally from mongoDB so that it remains logged in

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #10

            You could store the user data in Qsettings. When opening the db check if there is a username filled in already.
            If it is don't show the authentification display but use the credentials from Qsettings.

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #11

              @Eddy I'd avoid plain QSettings for that, the credentials would be stored in plain text. Credentials are sensitive information that should be encrypted.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • EddyE Offline
                EddyE Offline
                Eddy
                wrote on last edited by
                #12

                @SGaist Yes, you're right, my bad.

                It depends how strict the teacher will be for this school assignment ;-)

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jiji
                  wrote on last edited by
                  #13

                  In the main method I use : engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); to display the authentification. So where I should put Qsettings!!??

                  1 Reply Last reply
                  0
                  • EddyE Offline
                    EddyE Offline
                    Eddy
                    wrote on last edited by
                    #14
                    In the main method I use : engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
                    

                    Thanks for letting us know you are using QML...

                    Have a look at this link if you are not concerned with encryption yet.

                    Qt Certified Specialist
                    www.edalsolutions.be

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      jiji
                      wrote on last edited by
                      #15

                      I want to create session because I have list that I declare in the main using context property as following:
                      int main(int argc, char argv[])
                      {
                      QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                      qputenv("QT_QUICK_CONTROLS_STYLE", "material");
                      QGuiApplication app(argc, argv);
                      ApplicationUI appui;
                      QQmlApplicationEngine engine;
                      QQmlContext
                      context = engine.rootContext();
                      context->setContextProperty("myApp", &appui);

                      //Users list
                      QList<User*> listuser;
                      listuser=u.getallUser() ;
                      UserEntityModel modeluser;
                      for(int i =0;i<listuser.size();i++ )
                      {
                      QString fullname = listuser[i]->fullname();
                      QString email= listuser[i]->Email();
                      QString grade= listuser[i]->grade();
                      QString evaluation = listuser[i]->evaluation();
                      QString photo=listuser[i]->photo();
                      modeluser.addUserEntity(UserEntity(fullname,email,grade,evaluation,photo));
                      }
                      context->setContextProperty("userModel", &modeluser);
                      engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
                      return app.exec();
                      }
                      For now I want to display the lists according to the logged user saved in session
                      But I can't refresh the list declared in the main, and it always shows me the lists of the last connection .
                      So I want to know how can refresh a list in real time.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        You should implement a class that does proper user management and updates the model as needed.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          jiji
                          wrote on last edited by jiji
                          #17

                          @SGaist please can you explain to me better, I didn't understand what I should to do!!!
                          And in QML I use the list model as following:
                          ListView {
                          id: listViewuser
                          anchors.bottomMargin: -3
                          anchors.leftMargin: -18
                          anchors.topMargin: -3
                          anchors.rightMargin: 5
                          focus: true
                          clip: true
                          anchors.fill: parent
                          model:userModel
                          delegate: userComponent
                          section.property: "sortGroup"
                          section.criteria: ViewSection.FullString
                          section.delegate: stateChanged
                          }

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #18

                            Since it seems that your user may change while your application is running, you should have a class which goal is to handle user management and part of its job would be to update that list.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            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