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. QMessageBox showing "Loading...."

QMessageBox showing "Loading...."

Scheduled Pinned Locked Moved Unsolved General and Desktop
32 Posts 7 Posters 13.0k Views 3 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.
  • GuapoG Offline
    GuapoG Offline
    Guapo
    wrote on last edited by Guapo
    #20

    This is for restaurant app. Here in Brazil, all restaurants needs a device called SAT, connected to USB and the internet (to send all sales data to our beloved government) :). This device has its own library to create a sale invoice and send all data to government.
    Load by hand is the way used to access the internal functions.
    I don´t know another way to acess internal function from a .dll or .so .
    My intention is open a screen to warning loading, because the user could think software is crashed. This library takes a several seconds to load.

    jsulmJ 1 Reply Last reply
    0
    • GuapoG Guapo

      This is for restaurant app. Here in Brazil, all restaurants needs a device called SAT, connected to USB and the internet (to send all sales data to our beloved government) :). This device has its own library to create a sale invoice and send all data to government.
      Load by hand is the way used to access the internal functions.
      I don´t know another way to acess internal function from a .dll or .so .
      My intention is open a screen to warning loading, because the user could think software is crashed. This library takes a several seconds to load.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #21

      @Guapo said in Qmessagebox showing "Loading....":

      I don´t know another way to acess internal function from a .dll or .so

      Usually you link your app against a library to use it.
      See http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      GuapoG 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Guapo said in Qmessagebox showing "Loading....":

        I don´t know another way to acess internal function from a .dll or .so

        Usually you link your app against a library to use it.
        See http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

        GuapoG Offline
        GuapoG Offline
        Guapo
        wrote on last edited by
        #22

        @jsulm

        when I tried to use this library, my first option was
        at my .pro file

        LIBS += -L"/mnt/midia4/prj/qt/Controle" -lDarumaFramework

        But I cannot exec the internal function ( ex: rVerificarComunicacao_SAT_Daruma() ).

        So, I received from the library owner a file to load it´s library and execute internal functions;

                 bibliotecaDinamica = dlopen("./libDarumaFramework.so", RTLD_NOW); 
        

        This is working!

        Today, I tried to include this line at my .pro file

        LIBS += -L"/mnt/midia4/prj/qt/Controle" -lDarumaFramework -ldl

        The library loading is during the aplication load....I can exec the internal function.

        But this is all inside the Qt Creator....when I tried to exec my aplication from the CL, there is a segmentation fault.
        I need more information, but this note is only to update you that I´m studying your hint.

        tks

        JonBJ 1 Reply Last reply
        0
        • GuapoG Guapo

          @jsulm

          when I tried to use this library, my first option was
          at my .pro file

          LIBS += -L"/mnt/midia4/prj/qt/Controle" -lDarumaFramework

          But I cannot exec the internal function ( ex: rVerificarComunicacao_SAT_Daruma() ).

          So, I received from the library owner a file to load it´s library and execute internal functions;

                   bibliotecaDinamica = dlopen("./libDarumaFramework.so", RTLD_NOW); 
          

          This is working!

          Today, I tried to include this line at my .pro file

          LIBS += -L"/mnt/midia4/prj/qt/Controle" -lDarumaFramework -ldl

          The library loading is during the aplication load....I can exec the internal function.

          But this is all inside the Qt Creator....when I tried to exec my aplication from the CL, there is a segmentation fault.
          I need more information, but this note is only to update you that I´m studying your hint.

          tks

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #23

          @Guapo said in Qmessagebox showing "Loading....":

                   bibliotecaDinamica = dlopen("./libDarumaFramework.so", RTLD_NOW); 
          

          But this is all inside the Qt Creator....when I tried to exec my aplication from the CL, there is a segmentation fault.

          1. You need to check the return result of dlopen, as it may fail? Do you proceed to use bibliotecaDinamica without verifying its value?

          2. ./libDarumaFramework.so is a relative path; it must be found in the current directory. Is your current directory right for this while running from QtCreator, but something else when run from the command line? (I don't know what dlopen's behaviour is exactly, but you might be better with plain libDarumaFramework.so without the leading ./.) Have you put the library in the same directory as your executable, along LD_LIBRARY_PATH, or what?

          GuapoG 1 Reply Last reply
          0
          • JonBJ JonB

            @Guapo said in Qmessagebox showing "Loading....":

                     bibliotecaDinamica = dlopen("./libDarumaFramework.so", RTLD_NOW); 
            

            But this is all inside the Qt Creator....when I tried to exec my aplication from the CL, there is a segmentation fault.

            1. You need to check the return result of dlopen, as it may fail? Do you proceed to use bibliotecaDinamica without verifying its value?

            2. ./libDarumaFramework.so is a relative path; it must be found in the current directory. Is your current directory right for this while running from QtCreator, but something else when run from the command line? (I don't know what dlopen's behaviour is exactly, but you might be better with plain libDarumaFramework.so without the leading ./.) Have you put the library in the same directory as your executable, along LD_LIBRARY_PATH, or what?

            GuapoG Offline
            GuapoG Offline
            Guapo
            wrote on last edited by
            #24

            @JNBarchan

            Yes...my library is on the same directory as my executable.

            int main(int argc, char *argv[])
            {
            QApplication a(argc, argv);

            qDebug()<< "inicio";
            
            Login w;
            
            w.show();
            
            return a.exec();
            

            }

            The segmentation fault occours before "inicio". (only executing in CL at the directory where are all files....this code is ok executing inside the Qt Creator ).

            jsulmJ 1 Reply Last reply
            0
            • GuapoG Guapo

              @JNBarchan

              Yes...my library is on the same directory as my executable.

              int main(int argc, char *argv[])
              {
              QApplication a(argc, argv);

              qDebug()<< "inicio";
              
              Login w;
              
              w.show();
              
              return a.exec();
              

              }

              The segmentation fault occours before "inicio". (only executing in CL at the directory where are all files....this code is ok executing inside the Qt Creator ).

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #25

              @Guapo If you want to execute your app outside of QtCreator you need to deploy it.
              See http://doc.qt.io/qt-5/deployment.html

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              GuapoG 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Guapo If you want to execute your app outside of QtCreator you need to deploy it.
                See http://doc.qt.io/qt-5/deployment.html

                GuapoG Offline
                GuapoG Offline
                Guapo
                wrote on last edited by
                #26

                @jsulm

                I´m trying do execute my aplication only for tests. I´m executing it at the same folder as compiled.

                When I do not use this line:

                LIBS += -L"/mnt/midia4/prj/qt/Controle" -lDarumaFramework -ldl

                It is possible execute it from CL.

                When I need to make deployment, I´ve used linuxdeployqt script.

                jsulmJ 1 Reply Last reply
                0
                • GuapoG Guapo

                  @jsulm

                  I´m trying do execute my aplication only for tests. I´m executing it at the same folder as compiled.

                  When I do not use this line:

                  LIBS += -L"/mnt/midia4/prj/qt/Controle" -lDarumaFramework -ldl

                  It is possible execute it from CL.

                  When I need to make deployment, I´ve used linuxdeployqt script.

                  jsulmJ Online
                  jsulmJ Online
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #27

                  @Guapo You can set LD_LIBRARY_PATH to point to the directory where this lib is and then start your app, see http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  GuapoG 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Guapo You can set LD_LIBRARY_PATH to point to the directory where this lib is and then start your app, see http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

                    GuapoG Offline
                    GuapoG Offline
                    Guapo
                    wrote on last edited by Guapo
                    #28

                    @jsulm excuse me for this delay.

                    I found a performance problem and I need to fix it before.

                    I don´t know if it´s better open a new point to discuss.

                    This code has an answer in 1sec. This exec a function "EnviarDadosVenda" from my external lib.

                    
                    #include <dlfcn.h>
                    #include <stdio.h>
                    #include <stdlib.h>
                    #include <string.h>
                    #include <inttypes.h>
                    #include <time.h>
                    
                    #include "helpers.c"
                    
                    int main(int argc, char *argv[]) 
                    {
                    	char * (*_EnviarDadosVenda) (int, char *, char *);
                    
                    	void * handle;
                    	char * error;
                    	char * resposta;
                    	char cXML[5000];
                    
                    	strcpy(cXML, "this is for XML");
                    
                    	handle = dlopen ("./libsat.so", RTLD_LAZY);
                    
                    	_EnviarDadosVenda = dlsym(handle, "EnviarDadosVenda");
                    
                        typedef char* (*funcao)(int, char*, char*);
                        funcao runGui = (funcao)dlsym(handle, "EnviarDadosVenda");
                    
                        resposta = runGui(_sessao(),"12345678", cXML);  // 1sec to return data
                    
                    	printf("======================================================\n");
                    	printf("\nExecutando funcao: _EnviarDadosVenda2\n");
                    	printf("\nRetorno: %s\n\n", (char *) resposta);
                    	printf("==++==================================================\n");
                    }
                    
                    

                    This function, running in qt, runs the same code in 16 secs. It´s the same function and the same lib.

                    char * EnviarDadosVenda2_libsat(int numerossessao, QString codigoativacao, QString pszXML){
                        char * resposta;
                        char cXML[1100];
                    
                        QDateTime agora=QDateTime::currentDateTime();
                        char* _EnviarDadosVenda(int , char*, char*);
                    
                        strcpy(cXML, "My XML data");
                    
                        void* handle = dlopen("./libsat.so", RTLD_LAZY);
                    
                        typedef char* (*funcao)(int, char*, char*);
                        funcao runGui = (funcao)dlsym(handle, "EnviarDadosVenda");
                    
                        qDebug() << "Vai executar EnviarDadosVenda2_libsat";
                    
                        resposta = runGui(numerossessao,"12345678", cXML);  // 16 seconds to return data
                    
                        qDebug() << "saiu EnviarDadosVenda2_libsat " << QDateTime::currentDateTime().toTime_t()-agora.toTime_t();
                    
                        return resposta;
                    
                    }
                    
                    
                    jsulmJ 1 Reply Last reply
                    0
                    • GuapoG Guapo

                      @jsulm excuse me for this delay.

                      I found a performance problem and I need to fix it before.

                      I don´t know if it´s better open a new point to discuss.

                      This code has an answer in 1sec. This exec a function "EnviarDadosVenda" from my external lib.

                      
                      #include <dlfcn.h>
                      #include <stdio.h>
                      #include <stdlib.h>
                      #include <string.h>
                      #include <inttypes.h>
                      #include <time.h>
                      
                      #include "helpers.c"
                      
                      int main(int argc, char *argv[]) 
                      {
                      	char * (*_EnviarDadosVenda) (int, char *, char *);
                      
                      	void * handle;
                      	char * error;
                      	char * resposta;
                      	char cXML[5000];
                      
                      	strcpy(cXML, "this is for XML");
                      
                      	handle = dlopen ("./libsat.so", RTLD_LAZY);
                      
                      	_EnviarDadosVenda = dlsym(handle, "EnviarDadosVenda");
                      
                          typedef char* (*funcao)(int, char*, char*);
                          funcao runGui = (funcao)dlsym(handle, "EnviarDadosVenda");
                      
                          resposta = runGui(_sessao(),"12345678", cXML);  // 1sec to return data
                      
                      	printf("======================================================\n");
                      	printf("\nExecutando funcao: _EnviarDadosVenda2\n");
                      	printf("\nRetorno: %s\n\n", (char *) resposta);
                      	printf("==++==================================================\n");
                      }
                      
                      

                      This function, running in qt, runs the same code in 16 secs. It´s the same function and the same lib.

                      char * EnviarDadosVenda2_libsat(int numerossessao, QString codigoativacao, QString pszXML){
                          char * resposta;
                          char cXML[1100];
                      
                          QDateTime agora=QDateTime::currentDateTime();
                          char* _EnviarDadosVenda(int , char*, char*);
                      
                          strcpy(cXML, "My XML data");
                      
                          void* handle = dlopen("./libsat.so", RTLD_LAZY);
                      
                          typedef char* (*funcao)(int, char*, char*);
                          funcao runGui = (funcao)dlsym(handle, "EnviarDadosVenda");
                      
                          qDebug() << "Vai executar EnviarDadosVenda2_libsat";
                      
                          resposta = runGui(numerossessao,"12345678", cXML);  // 16 seconds to return data
                      
                          qDebug() << "saiu EnviarDadosVenda2_libsat " << QDateTime::currentDateTime().toTime_t()-agora.toTime_t();
                      
                          return resposta;
                      
                      }
                      
                      
                      jsulmJ Online
                      jsulmJ Online
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by jsulm
                      #29

                      @Guapo Well, I don't know why this difference. Are you sure you pass exactly the same data to EnviarDadosVenda in both cases?
                      Also you wrote runGui takes 16 seconds to execute, but actually you measure time for copying the data, loading the library and resolving the symbol as well. Loading a library and resolving symbols can take some time, move

                      QDateTime agora=QDateTime::currentDateTime();
                      

                      just before you call runGui.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      GuapoG 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @Guapo Well, I don't know why this difference. Are you sure you pass exactly the same data to EnviarDadosVenda in both cases?
                        Also you wrote runGui takes 16 seconds to execute, but actually you measure time for copying the data, loading the library and resolving the symbol as well. Loading a library and resolving symbols can take some time, move

                        QDateTime agora=QDateTime::currentDateTime();
                        

                        just before you call runGui.

                        GuapoG Offline
                        GuapoG Offline
                        Guapo
                        wrote on last edited by
                        #30

                        @jsulm yes...I´m sure the input data are the same at the both cases.

                        This xml string has more than 1000 bytes.

                        I made another test using this same function in a exclusive qt project that contain only this function and this function delay 1sec.

                        There is something in my project that retards the execution.

                        jsulmJ 1 Reply Last reply
                        0
                        • GuapoG Guapo

                          @jsulm yes...I´m sure the input data are the same at the both cases.

                          This xml string has more than 1000 bytes.

                          I made another test using this same function in a exclusive qt project that contain only this function and this function delay 1sec.

                          There is something in my project that retards the execution.

                          jsulmJ Online
                          jsulmJ Online
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #31

                          @Guapo But did you change the way you measure the execution time? As I said in the code you posted you're measuring also library loading and symbol resolution.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          GuapoG 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @Guapo But did you change the way you measure the execution time? As I said in the code you posted you're measuring also library loading and symbol resolution.

                            GuapoG Offline
                            GuapoG Offline
                            Guapo
                            wrote on last edited by
                            #32

                            @jsulm I found the problem about 16 secs...it´s a bad implementation of EnviarDadosVenda ( external library )....there is a parameter ( random ) and if this number is greater than 999.999, EnviarDadosVenda takes 16 secs to answer...this is out of spec. I contacted the suplier to inform this issue.

                            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