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. new QProgressDialog - QProgressBar displayed on first time only.
Forum Updated to NodeBB v4.3 + New Features

new QProgressDialog - QProgressBar displayed on first time only.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 504 Views 1 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.
  • SeDiS Offline
    SeDiS Offline
    SeDi
    wrote on last edited by SeDi
    #1

    Hi,
    when user calls the sendAll routine below, I construct a new QProgressDialog from scratch, set the necessary stuff, open it and keep it updated. It shows the progress as intended. Afterwards it is closed and deleted.

    But: calling sendAllSlot a second (third...) time, though the dialog opens, the progress bar itself is never to be seen. I have also tried this with a QProgressBar, same problem. It works only on first run.

    I guess that I am doing something fundamentally and idiotically wrong. But what?

    void MainWindow::sendAllSlot()
    {
        bool sent = true;
        if (QMessageBox::question(nullptr, "Alle versenden","Sind Sie sicher?")
                == QMessageBox::Yes) {
            int i = 0;
            QProgressDialog *p = new QProgressDialog();
            p->reset();
            p->setMinimum(0);
            p->setValue(0);
            p->setMaximum(m_recipientsFiltered.count());
            p->setMinimumDuration(1);
            p->show();
            for (; i < m_recipientsFiltered.count(); i++) {
                p->setValue(i);
                Recipient* r = m_recipientsFiltered.at(i);
    
                sent = sendOneMail(r);
                if (!sent) {
                    // User has not provided sufficient information. We leave the for-loop before doing anything.
                    QMessageBox::about(nullptr, "Abbruch", "Der Vorgang wurde abgebrochen");
                    break;
                }
            }
            p->reset();
            p->close();
            delete p;
        }
    }
    
    1 Reply Last reply
    0
    • SeDiS Offline
      SeDiS Offline
      SeDi
      wrote on last edited by
      #2

      Ok, solved.

      p->setModal(true);
      

      finally did the trick for me. I'll leave this for people with the same problem.

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

        Hi,

        Since you only use that dialog within that method, you can use the stack rather than the heap. It will automatically delete the dialog at the end of the if statement.

        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

        • Login

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