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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    What do you mean by "because it's transparent" ? What exactly is transparent ?

    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
    • GuapoG Guapo

      I´m trying to put a message during the loading of my library.

      QMessageBox msgBox;
      msgBox.setText("Lendo Biblioteca SAT.");
      msgBox.setWindowTitle("Aguarde carregamento...");
      msgBox.setWindowModality(Qt::WindowModal);
      msgBox.setVisible(true);
      msgBox.show();
      

      This code doesn´t show the text, because it´s transparent and it´s showing the background.

      What am i doing wrong?

      thanks

      Venkatesh VV Offline
      Venkatesh VV Offline
      Venkatesh V
      wrote on last edited by
      #3

      @Guapo

      Hi,

      You can set stylesheet to the messageBox text.
      Try this,
      msgBox.setstylesheet(background-color:#0F1418;color:white;font-size:11pt;)

      1 Reply Last reply
      1
      • GuapoG Offline
        GuapoG Offline
        Guapo
        wrote on last edited by
        #4

        ![alt text](0_1510129692680_sat1.png image url)

        Good Morning!

        This is what I mean transparent....my messagebox doesn´t a background color.

        QMessageBox msgBox;
        msgBox.setText("Lendo Biblioteca SAT.");
        msgBox.setWindowTitle("Aguarde carregamento...");
        msgBox.setWindowModality(Qt::WindowModal);
        msgBox.setStyleSheet("background-color:#0F1418;color:white;font-size:11pt");
        msgBox.setVisible(true);
        msgBox.show();
        

        @Venkatesh-V ... I tried your sugestion and the results are the same.

        tks

        M 1 Reply Last reply
        0
        • Vinod KuntojiV Offline
          Vinod KuntojiV Offline
          Vinod Kuntoji
          wrote on last edited by
          #5

          @Guapo ,

          Try ,
          msgBox.exec() instead of msgBox.show();

          C++, Qt, Qt Quick Developer,
          PthinkS, Bangalore

          1 Reply Last reply
          0
          • GuapoG Guapo

            ![alt text](0_1510129692680_sat1.png image url)

            Good Morning!

            This is what I mean transparent....my messagebox doesn´t a background color.

            QMessageBox msgBox;
            msgBox.setText("Lendo Biblioteca SAT.");
            msgBox.setWindowTitle("Aguarde carregamento...");
            msgBox.setWindowModality(Qt::WindowModal);
            msgBox.setStyleSheet("background-color:#0F1418;color:white;font-size:11pt");
            msgBox.setVisible(true);
            msgBox.show();
            

            @Venkatesh-V ... I tried your sugestion and the results are the same.

            tks

            M Offline
            M Offline
            mostefa
            wrote on last edited by
            #6

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

            ![alt text](0_1510129692680_sat1.png image url)

            Good Morning!

            This is what I mean transparent....my messagebox doesn´t a background color.

            QMessageBox msgBox;
            msgBox.setText("Lendo Biblioteca SAT.");
            msgBox.setWindowTitle("Aguarde carregamento...");
            msgBox.setWindowModality(Qt::WindowModal);
            msgBox.setStyleSheet("background-color:#0F1418;color:white;font-size:11pt");
            msgBox.setVisible(true);
            msgBox.show();
            

            @Venkatesh-V ... I tried your sugestion and the results are the same.

            tks

            Normally the QMessageBox is not transparent by default , are you changing stylesheet, style or palette somewhere else in your code?

            I don't think that this part of the code is responsible of making messagebox transparent

            QMessageBox msgBox;
            msgBox.setText("Lendo Biblioteca SAT.");
            msgBox.setWindowTitle("Aguarde carregamento...");
            msgBox.setWindowModality(Qt::WindowModal);
            msgBox.setStyleSheet("background-color:#0F1418;color:white;font-size:11pt");
            msgBox.setVisible(true);
            msgBox.show();

            Can you share other parts of your code?

            1 Reply Last reply
            1
            • GuapoG Offline
              GuapoG Offline
              Guapo
              wrote on last edited by
              #7

              I didn´t change the stylesheet.

              This is the second class called in my program...the first one is for login.

              If I change msgBox.show to msgBox.exec...it´s ok, but don´t load my library until press "ok" button.

              This is the entire constructor class:

              Principal::Principal(QWidget *parent) :
                  QDialog(parent),
                  ui(new Ui::Principal)
              {
                  ui->setupUi(this);
              
                  QPixmap pix(QString("%1%2").arg(path_images,"selo_sabordelivery.png"));
                  ui->label_pic_2->setPixmap(pix);
                  ui->label_pic_3->setPixmap(pix);
                  ui->label_pic_3->setPixmap(pix);
                  ui->label_pic_4->setPixmap(pix);
                  ui->label_pic_5->setPixmap(pix);
              
                  ui->label_nomeuser->setText(user_logado);
                  ui->label_status->setText(Utility::JobTitle(user_tipo));
                  ui->label_nome->setText(user_nome);
              
                  qDebug() << user_logado << user_status;
              
                  conn.connOpen();
              
                  QDateTime timeConvertor=QDateTime::currentDateTime();
                  QDateTime licenca;
              
                  QString validade=lerlicenca();
                  licenca = QDateTime::fromString(validade, "dd/MM/yyyy");
                  if(licenca.toTime_t()>=timeConvertor.toTime_t())
                      validade_ok=true;
                  qDebug() << validade << validade_ok;
              
                  Acesso();
              
                  ui->label_versao->setText(VERSAO);
              
                  model_loja=new QSqlQueryModel();
                  lerloja(model_loja);
                  config=model_loja->record(0).value(4).toInt();
                  qDebug() << config;
              
                  LerModos();
              
                  QMessageBox msgBox;
                  msgBox.setText("Lendo Biblioteca SAT.");
                  msgBox.setWindowTitle("Aguarde carregamento...");
                  msgBox.setWindowModality(Qt::WindowModal);
                  msgBox.setStyleSheet("background-color:#0F1418;color:white;font-size:11pt");
                  msgBox.setVisible(true);
                  msgBox.show();
              
                  if(nomesat!="")
                      carregarDarumaFramework(this);
              }
              

              tks

              Venkatesh VV jsulmJ 2 Replies Last reply
              0
              • GuapoG Guapo

                I didn´t change the stylesheet.

                This is the second class called in my program...the first one is for login.

                If I change msgBox.show to msgBox.exec...it´s ok, but don´t load my library until press "ok" button.

                This is the entire constructor class:

                Principal::Principal(QWidget *parent) :
                    QDialog(parent),
                    ui(new Ui::Principal)
                {
                    ui->setupUi(this);
                
                    QPixmap pix(QString("%1%2").arg(path_images,"selo_sabordelivery.png"));
                    ui->label_pic_2->setPixmap(pix);
                    ui->label_pic_3->setPixmap(pix);
                    ui->label_pic_3->setPixmap(pix);
                    ui->label_pic_4->setPixmap(pix);
                    ui->label_pic_5->setPixmap(pix);
                
                    ui->label_nomeuser->setText(user_logado);
                    ui->label_status->setText(Utility::JobTitle(user_tipo));
                    ui->label_nome->setText(user_nome);
                
                    qDebug() << user_logado << user_status;
                
                    conn.connOpen();
                
                    QDateTime timeConvertor=QDateTime::currentDateTime();
                    QDateTime licenca;
                
                    QString validade=lerlicenca();
                    licenca = QDateTime::fromString(validade, "dd/MM/yyyy");
                    if(licenca.toTime_t()>=timeConvertor.toTime_t())
                        validade_ok=true;
                    qDebug() << validade << validade_ok;
                
                    Acesso();
                
                    ui->label_versao->setText(VERSAO);
                
                    model_loja=new QSqlQueryModel();
                    lerloja(model_loja);
                    config=model_loja->record(0).value(4).toInt();
                    qDebug() << config;
                
                    LerModos();
                
                    QMessageBox msgBox;
                    msgBox.setText("Lendo Biblioteca SAT.");
                    msgBox.setWindowTitle("Aguarde carregamento...");
                    msgBox.setWindowModality(Qt::WindowModal);
                    msgBox.setStyleSheet("background-color:#0F1418;color:white;font-size:11pt");
                    msgBox.setVisible(true);
                    msgBox.show();
                
                    if(nomesat!="")
                        carregarDarumaFramework(this);
                }
                

                tks

                Venkatesh VV Offline
                Venkatesh VV Offline
                Venkatesh V
                wrote on last edited by
                #8

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

                msgBox.setWindowModality(Qt::WindowModal);

                instead can you try by Qt::ApplicationModal

                1 Reply Last reply
                0
                • GuapoG Guapo

                  I didn´t change the stylesheet.

                  This is the second class called in my program...the first one is for login.

                  If I change msgBox.show to msgBox.exec...it´s ok, but don´t load my library until press "ok" button.

                  This is the entire constructor class:

                  Principal::Principal(QWidget *parent) :
                      QDialog(parent),
                      ui(new Ui::Principal)
                  {
                      ui->setupUi(this);
                  
                      QPixmap pix(QString("%1%2").arg(path_images,"selo_sabordelivery.png"));
                      ui->label_pic_2->setPixmap(pix);
                      ui->label_pic_3->setPixmap(pix);
                      ui->label_pic_3->setPixmap(pix);
                      ui->label_pic_4->setPixmap(pix);
                      ui->label_pic_5->setPixmap(pix);
                  
                      ui->label_nomeuser->setText(user_logado);
                      ui->label_status->setText(Utility::JobTitle(user_tipo));
                      ui->label_nome->setText(user_nome);
                  
                      qDebug() << user_logado << user_status;
                  
                      conn.connOpen();
                  
                      QDateTime timeConvertor=QDateTime::currentDateTime();
                      QDateTime licenca;
                  
                      QString validade=lerlicenca();
                      licenca = QDateTime::fromString(validade, "dd/MM/yyyy");
                      if(licenca.toTime_t()>=timeConvertor.toTime_t())
                          validade_ok=true;
                      qDebug() << validade << validade_ok;
                  
                      Acesso();
                  
                      ui->label_versao->setText(VERSAO);
                  
                      model_loja=new QSqlQueryModel();
                      lerloja(model_loja);
                      config=model_loja->record(0).value(4).toInt();
                      qDebug() << config;
                  
                      LerModos();
                  
                      QMessageBox msgBox;
                      msgBox.setText("Lendo Biblioteca SAT.");
                      msgBox.setWindowTitle("Aguarde carregamento...");
                      msgBox.setWindowModality(Qt::WindowModal);
                      msgBox.setStyleSheet("background-color:#0F1418;color:white;font-size:11pt");
                      msgBox.setVisible(true);
                      msgBox.show();
                  
                      if(nomesat!="")
                          carregarDarumaFramework(this);
                  }
                  

                  tks

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @Guapo I don't think the dialog is transparent. It looks more like your dialog/app is hanging and so not updating/painting the UI. Do you block the event loop somewhere?

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

                  1 Reply Last reply
                  1
                  • JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #10

                    Exactly as @jsulm says above. No stylesheet, rather this is what a window/message box looks like when it has "started" to be shown but has not "completed", as in some shape or form your app is "blocking"/looping" where it needs to allow the main event loop to be processing events....

                    1 Reply Last reply
                    0
                    • GuapoG Offline
                      GuapoG Offline
                      Guapo
                      wrote on last edited by
                      #11

                      @Venkatesh-V said in Qmessagebox showing "Loading....":

                      ApplicationModal

                      I tried ApplicationModal, NonModal and WindowModal...nok!

                      I have no blocked anything because this is the beginning of my aplication....

                      1)read user/password (first screen)
                      2)read third party library and open main screen. (2nd screen)

                      This messagebox is inside of the main screen constructor.

                      LerModos -> function read sqltable
                      ...
                      carregarDarumaFramework -> load a huge third party library

                      tks

                      JonBJ 1 Reply Last reply
                      0
                      • GuapoG Guapo

                        @Venkatesh-V said in Qmessagebox showing "Loading....":

                        ApplicationModal

                        I tried ApplicationModal, NonModal and WindowModal...nok!

                        I have no blocked anything because this is the beginning of my aplication....

                        1)read user/password (first screen)
                        2)read third party library and open main screen. (2nd screen)

                        This messagebox is inside of the main screen constructor.

                        LerModos -> function read sqltable
                        ...
                        carregarDarumaFramework -> load a huge third party library

                        tks

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #12

                        @Guapo
                        I could be way, way out on this... but I still suspect painting/event loop...
                        You're halfway thru constructing a "man screen" (QMainWindow?) when you decide to put up a message box...
                        Temporarily, why don't you move the message box later, after the main screen has been constructed and shown, and then see? At least that will eliminate stylesheets etc.

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

                          To complement what @JNBarchan suggests, you should likely move the library loading part outside the constructor of your MainWidget since it's not related to the contraction of that widget.

                          Basically, create your gui elements and once that's done, trigger the loading/setup of whatever is 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
                          3
                          • GuapoG Offline
                            GuapoG Offline
                            Guapo
                            wrote on last edited by
                            #14

                            I did make some changes...

                            The first action of my app is ask for user/pass to login on.

                            There is a "Login" button to check these credencials.

                            After check user and pass I put this library load and my &$&#$%%@# QMessagebox.

                            When this load finish, I call the Principal class ( that shows the main screen ).

                            The old code had this Principal class constructor to load this library.

                            Now I´m loading this library out of any constructor and the results are exactly I the same.

                            JonBJ 1 Reply Last reply
                            0
                            • GuapoG Guapo

                              I did make some changes...

                              The first action of my app is ask for user/pass to login on.

                              There is a "Login" button to check these credencials.

                              After check user and pass I put this library load and my &$&#$%%@# QMessagebox.

                              When this load finish, I call the Principal class ( that shows the main screen ).

                              The old code had this Principal class constructor to load this library.

                              Now I´m loading this library out of any constructor and the results are exactly I the same.

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by JonB
                              #15

                              @Guapo
                              But are you calling the Message Box creation after you have entered the main Qt event loop (like app.exec_()) which has allowed the main window to finish drawing correctly? Or, possibly, very early, before you have started creating your QMainWindow? Or, what's this "third-party library" you're talking about, could that be interfering, why can't you eliminate that and see if it's relevant?

                              It's up to you whether you want to try these things. But if you don't, I could be wrong but it seems to me nobody here is going to have a solution for you....

                              1 Reply Last reply
                              0
                              • GuapoG Offline
                                GuapoG Offline
                                Guapo
                                wrote on last edited by Guapo
                                #16

                                @JNBarchan

                                The Login Class is my QMainWindow.

                                int main(int argc, char *argv[])
                                {
                                    QApplication a(argc, argv);
                                    Login w;
                                
                                    w.show();
                                
                                    return a.exec();
                                }
                                
                                ........
                                
                                Login::Login(QWidget *parent) :
                                    QMainWindow(parent),
                                    ui(new Ui::Login)
                                {
                                    ui->setupUi(this);
                                
                                    path_images=QString("%1/images/").arg(QDir::currentPath());
                                    QPixmap pix(QString("%1%2").arg(path_images,"selo_sabordelivery.png"));
                                 //   QPixmap pix("/mnt/midia4/prj/qt/sql/sql_app/selo_sabordelivery.png");
                                    ui->label_pic->setPixmap(pix);
                                
                                    if(!connOpen())
                                        ui->label_db->setText("Falha ao conectar DataBase");
                                    else
                                        ui->label_db->setText("DataBase Conectado...");
                                }
                                

                                and I´m loading my library (.so) inside this class...This class has a GUI.

                                I put this message before loading library and didn´t show anything....I´m trying to understand what is going on.

                                tks

                                jsulmJ 1 Reply Last reply
                                0
                                • GuapoG Guapo

                                  @JNBarchan

                                  The Login Class is my QMainWindow.

                                  int main(int argc, char *argv[])
                                  {
                                      QApplication a(argc, argv);
                                      Login w;
                                  
                                      w.show();
                                  
                                      return a.exec();
                                  }
                                  
                                  ........
                                  
                                  Login::Login(QWidget *parent) :
                                      QMainWindow(parent),
                                      ui(new Ui::Login)
                                  {
                                      ui->setupUi(this);
                                  
                                      path_images=QString("%1/images/").arg(QDir::currentPath());
                                      QPixmap pix(QString("%1%2").arg(path_images,"selo_sabordelivery.png"));
                                   //   QPixmap pix("/mnt/midia4/prj/qt/sql/sql_app/selo_sabordelivery.png");
                                      ui->label_pic->setPixmap(pix);
                                  
                                      if(!connOpen())
                                          ui->label_db->setText("Falha ao conectar DataBase");
                                      else
                                          ui->label_db->setText("DataBase Conectado...");
                                  }
                                  

                                  and I´m loading my library (.so) inside this class...This class has a GUI.

                                  I put this message before loading library and didn´t show anything....I´m trying to understand what is going on.

                                  tks

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #17

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

                                  connOpen

                                  what does this one do?

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

                                  1 Reply Last reply
                                  0
                                  • GuapoG Offline
                                    GuapoG Offline
                                    Guapo
                                    wrote on last edited by Guapo
                                    #18

                                    connOpen only it´s makes a MySql conection

                                    bool connOpen(){

                                        lerconf();  // read text file
                                    
                                        mydb=QSqlDatabase::addDatabase("QMYSQL");
                                        mydb.setDatabaseName("controle_restaurante");
                                    
                                        mydb.setHostName(database_nome);
                                        mydb.setPort(database_port.toInt());
                                        mydb.setUserName(database_user);
                                        mydb.setPassword(database_senha);
                                    
                                        if(!mydb.open()){
                                            qDebug() << "Falha ao conectar ao DataBase" << mydb.lastError().text();
                                            return false;
                                        }
                                        else{
                                            qDebug() << ("Conectado...");
                                            return true;
                                        }
                                    
                                    }
                                    
                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      Do you mean you want to have some sort of splash screen while that library is being loaded ?

                                      Out of curiosity, why do you need to load it by hand ?

                                      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
                                      • 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 Offline
                                          jsulmJ Offline
                                          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

                                          • Login

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