Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QProgressDialog without close button [duplicate]

Tags:

c++

qt

Is it possible to remove the close button (see screenshot) of a QProgressDialog? I couldn't find anything useful in the docs/Google.

I use a modal QProgressDialog to show infinite process and block the GUI until a lengthy operation has completed. Because the GUI should be blocked, I don't want the user to be able to close the dialog.

enter image description here

like image 840
sashoalm Avatar asked Jun 04 '13 14:06

sashoalm


1 Answers

You can hide close button of every window by clearing an appropriate flag:

With Qt 5.0

QProgressDialog dlg;
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowCloseButtonHint);

Qt::WindowCloseButtonHint 0x08000000 Adds a close button. On some platforms this implies Qt::WindowSystemMenuHint for it to work.

With earlier versions

    QProgressDialog dlg;
    dlg.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);

where

  • Qt::Window stands for window
  • Qt::WindowTitleHint stands for displaying title on the top of the window
  • Qt::CustomizeWindowHint stands for not displaying buttons
like image 200
Lol4t0 Avatar answered Oct 28 '22 12:10

Lol4t0