Qt: how can I place the main window in the background and im handle the window in forground?

I use the Qt framework, and I am looking for the best way to show how the user im processes something
like in Qt I can:
put the main window in the background and a pop-up window in the foreground, for example, "processing" the massage
until its processing is completed, the window The "processing" closes and the main window returns to the foreground.

+3
source share
3 answers

QProgressDialog. . QProgressDialog , . QProgressDialog .

Edit:

QProgressBar : .

QProgressDialog , , QProgressDialog 0, . QProgressDialog , setBar(). min, max 0, .

QProgressDialog progressDialog("Processing...", "Abort", 0, INT_MAX, this);

QProgressBar* bar = new QProgressBar(&progressDialog);
bar->setRange(0, 0);
bar->setValue(0);
progress.setBar(bar);

progressDialog.setMinimumWidth(350);
progressDialog.setMinimumDuration(1000);
progressDialog.setWindowModality(Qt::WindowModal);
progressDialog.setValue(0);


// Do your time consuming processing here, but remember to change 
// the progress dialog value a few times per second. 
// That will keep the busy indicator moving.
progressDialog.setValue(progressDialog.value() + 1);

// And check if the user has cancelled the processing
if (progressDialog.wasCanceled())
    break or return or whatever necessary


// When your processing is done, close the dialog.
progressDialog.close();
+8

:

  • , , .
  • Show(). , .

    emit NameOfSignal;

,

Edit:

setDisabled hide setEnabled .

+4

You can specify "Processing" -enable Qt::WindowStaysOnTopHintso that it stays on top of the disabled main window.

If you don't like this, you can blur your main window using QGraphicsBlurEffect while the processing window is on top. Thus, the user receives a message that the main window is not available until your processing is completed.

+3
source

Source: https://habr.com/ru/post/1762840/


All Articles