0

I'm developing an app which is mainly a file browser. I need to create a Progress Indication when deleting files to show the progress to the user.

I have created one, but it's ugly and not working as expected.

Below is the look of Progress

enter image description here

this is not really sexy... I would expect a kind of cancel icon and having a window with more space around the progress indicator and why not a text saying : 1/10, 2/10...

The second issue I had is that it seems that the progress bar is not working correctly. The progress do not show up.

Below is the code used. QProgressBar is a method in my DialogBox Class.

void MyDialog::ProgressIndicator(uint32_t max_value) {

    //ProgressInd = new QProgressBar();
    ProgressInd.setRange(0,max_value);
    ProgressInd.setValue(0);
    ProgressInd.show();

}

void MyDialog::ProgressUpdate(uint32_t value) {
    ProgressInd.setValue(value);

}

void MyDialog::ProgressClose() {
    ProgressInd.close();
}

ProgressInd is defined in the header file as followed:

QProgressBar ProgressInd;

I'm using the ProgresBar in my code a:

    TreeBox->ProgressIndicator(item.count());
    for (int i=0; i<item.count();i++) {
        myItem = dynamic_cast<MyTreeWidgetItem*>(item[i]);
        if((myItem->item_id == INVALID) || (myItem->id == INVALID)) {
            /* Shouldn't happened as id must be filed at creation */
            /* safety mechanism */
            delete myItem;
        }
        else {
            error = m_device.DeleteFile(myItem_id);

            if(error == ERROR_NONE)
            {
                delete myItem;

            }
            else {
                TreeBox->NotificationBox("File(s) deletion Failed");
                TreeBox->ProgressClose();                    
                return;
            }
        }
        TreeBox->ProgressUpdate(i++);
    }
    TreeBox->ProgressClose();
Seb
  • 2,929
  • 4
  • 30
  • 73
  • You really need to show complete example code! Without that, I'm guessing that the deletion of files is on the Gui thread and you're not giving time to the main event loop to process signals of updating progress. Please show more code, specifically where the deletion of files is occurring. Also be specific about the problem. When you state "the progress do not show up" [sic]), do you mean the dialog isn't shown, or it's shown, but doesn't update? – TheDarkKnight Mar 26 '15 at 16:58
  • @TheDarkKnight will add some text. For the Progress I speak about the update and the dialog is shown. otherwise I wouldn't be able to put a screenshot of the dialog box. – Seb Mar 26 '15 at 17:11
  • Probably what you want is QProgressDialog. [Docs](http://doc.qt.io/qt-5/qprogressdialog.html) – MKAROL Mar 26 '15 at 17:12
  • If you'd created the dialog in Qt Creator, you could have taken a screenshot of that, without having to run your program! As @MKAROL states, QProgressDialog would be better, unless you have a specific reason for not using it. – TheDarkKnight Mar 26 '15 at 17:17
  • 1
    If after calling TreeBox->ProgressUpdate(i++) you add a call to QApplication::processEvents( ), does that fix it? Note that this is just a test and you really shouldn't use processEvents. – TheDarkKnight Mar 26 '15 at 17:19
  • @TheDarkKnight thanks a lot. will try and move to QProgressDialog – Seb Mar 26 '15 at 17:31

0 Answers0