0

I have a QMainWindow window that shows a countdown for 10 seconds and will shutdown the system with system("sudo shutdown -P");. Of course I want to disable the "X", Max- and minimizer buttons from the title bar using setWindowFlags(). I used this->setWindowFlags(Qt::Window | Qt::CustomSizeWIndowHint | Qt::WindowSystemMenuHint) but unfortunately it is not working.

I Have already read this, this, this , this and this questions and also I ran the windowflags-example on my system and even this example did not work. I have a Raspberry Pi 2, compile and run my code on Raspbian Jessie using Qt 4.8.

Can anybody help me? thanks in advance!

Community
  • 1
  • 1
mohsen_og
  • 774
  • 1
  • 9
  • 31
  • If your WM doesn't understand Motif hints, Qt hints won't work. Try setting all these flags:CustomizeWindowHint|WindowTitleHint| WindowSystemMenuHint| WindowMinimizeButtonHint| WindowMaximizeButtonHint| WindowCloseButtonHint. – n. m. could be an AI Apr 22 '16 at 11:26
  • @Mogi Have you tried to give the flags to the QMainWindow constructor? – A. Sarid Apr 22 '16 at 11:26
  • 1
    You can override closeEvent(QCloseEvent* event) and ingnore event, like this: `void MainWindow::closeEvent(QCloseEvent* event) { event->ignore(); }` – Alexander Medvidov Apr 22 '16 at 11:52
  • @AlexanderMedvidov Thanks, in this case it might work but for instance I have a Login page as well that must be closed after a successful login. in this case the `closeEvent()` is useless since i need to close the login page using `this->close();`. – mohsen_og Apr 22 '16 at 12:09
  • @n.m. Hi and Thanks. How should I know if my Windows Manager (WM) understands the Motif hints? How can I set the flags? – mohsen_og Apr 22 '16 at 12:15
  • @A.Sarid Hi & thanks. I am using these flags in the constructor of my `ShutdownClass`. I have a `HelperClass` which inherits from the `public QMainWindow` and all my other classes iherits from `HelperClass`. Now what do you mean and how? Sorry I didn't get your comment. – mohsen_og Apr 22 '16 at 12:19
  • i suggest to set Qt::FramelessWindowHint to QMainWindow – tty6 Apr 22 '16 at 15:27
  • @Mogi Maybe separate modal window with override closeEvent?) – Alexander Medvidov Apr 22 '16 at 18:47
  • @tty6 Hi, I have used that so absolutely it gives me a framelessWindow which is not preffered. I cannot change this flag afterwards! – mohsen_og Apr 25 '16 at 07:38
  • @Mogi i suggest you to think about implementing your own custom min,max-close buttons with framelessWindowHint, besides you can use QWidget's setMask, this also can help – tty6 Apr 25 '16 at 08:45

0 Answers0