November 18, 2010

Luca Luca
Ant Farmer
590 posts

Remove minimize button from QDialog

 

Hi all,
I’m working in a Linux application.

I need to remove minimize button from a QDialog. I tried some solution without success.

The only one solution that works is:

  1. QDialog *parametri_dialog = new QDialog(widget_tab);
  2. parametri_dialog->setWindowFlags(parametri_dialog->windowFlags() | Qt::FramelessWindowHint);
  3. parametri_dialog->show();

but this way all button disappear and I also can’t resize dialog.

If I put the line:

  1. parametri_dialog->setWindowFlags(parametri_dialog->windowFlags() & ~(Qt::WindowMinimizeButtonHint));

nothing happend.

Can you help me?

7 replies

November 18, 2010

Volker Volker
Robot Herder
5428 posts

From Qt::WindowFlags docs [doc.qt.nokia.com]
The CustomizeWindowHint flag is used to enable customization of the window controls. This flag must be set to allow the WindowTitleHint, WindowSystemMenuHint, WindowMinimizeButtonHint, WindowMaximizeButtonHint and WindowCloseButtonHint flags to be changed.

So you should also set the Qt::CustomizeWindowHint flag.

November 18, 2010

Luca Luca
Ant Farmer
590 posts

I tried this:

  1. parametri_dialog->setWindowFlags(parametri_dialog->windowFlags() & ~(Qt::WindowMinimizeButtonHint) & Qt::CustomizeWindowHint);

but now dialog doesn’t show nothing…

November 18, 2010

Luca Luca
Ant Farmer
590 posts

Now I tried windowflags Qt example (from qt source) and there is no possibility to remove only minimize button an keep the possibility to move the dialog and resize it.

Can someone confirm me this?

November 18, 2010

Volker Volker
Robot Herder
5428 posts

This works for me:

  1. #include <QApplication>
  2. #include <QDialog>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.     QApplication a(argc, argv);
  7.     a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
  8.  
  9.     QDialog d;
  10.     d.setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint );
  11.     d.setWindowTitle("abcd");
  12.     d.show();
  13.  
  14.     return a.exec();
  15. }

You might set some other window flags too.

November 19, 2010

Luca Luca
Ant Farmer
590 posts

… unfortunately doesn’t works form me.

Are you using Linux or Windows?

November 19, 2010

Volker Volker
Robot Herder
5428 posts

I’m on a Mac.

On Linux, you might want to add Qt::WindowTitleHint to the flags.

Window decoration is platform dependend, so it could be that your approach is not achievable at all.

November 19, 2010

Luca Luca
Ant Farmer
590 posts

Thanks, now I think it’s not possible in linux.

 
  ‹‹ how does QWidget support stylesheet ?      [Solved] QFileSystemModel root path ››

You must log in to post a reply. Not a member yet? Register here!