PDA

View Full Version : Remove max,min button on a QMainWindow



Krish_ng
16th July 2007, 12:27
I have developed an application o Windows.While porting the application to Linux i encountered some problems.I had removed the max,min buttons on the QmainWindow by passing an argument Qt::WindowSystemMenuHint to the constructor.It worked fine on Windows OS but on porting to Linux minimize button on QMainWindow is visible.I even tried using setWindowFlags() but did not work...Anybody suggest some approach to solve the problem

rajesh
16th July 2007, 12:41
this following code working for me on window.this code removing all max, min and close button from window title.
first line of code making framless window then 2nd line adding only titlebar without button. I hope this will work for you


setWindowFlags(Qt::FramelessWindowHint);
setWindowFlags(Qt::WindowTitleHint);
setWindowTitle(tr("your title"));

Krish_ng
16th July 2007, 12:48
I tried with ur code...I am still getting the minimize buttton....I am not able remove the minimize button.....Any idea of window manager for Linux

rajesh
16th July 2007, 13:00
now you getting only minmize button or all buttons?
try this, first you make flag 0 then you add only Qt::WindowTitleHint.


Qt::WindowFlags flags = 0;
flags |= Qt::FramelessWindowHint;// i think this not required
flags |= Qt::WindowTitleHint;
myWindow->setWindowFlags(flags);

Krish_ng
16th July 2007, 13:29
I think by default minimize and close button on the window are visible. I tried testing setWindowFlags(Qt::WindowMaximizeButtonHint),even maximize button is also not visible.

nowire75
26th November 2007, 22:55
Hi,

I tray and retray the code for remove max botton on a QDialog window but it not work....
I use Qt4 on a kde desktop. I try this for remove a help button and it work fine:


Qt::WindowFlags flags = roboteditvar->windowFlags();
roboteditvar->move(pos);
roboteditvar->setWindowFlags(flags & ~Qt::WindowContextHelpButtonHint);
roboteditvar->show();

I have check the windowflags example on my computer, but also this not work for disable the WindowMaximizeButtonHint.

nowire

joshlareau
18th April 2011, 15:03
setWindowFlags( Qt::Window
| Qt::WindowTitleHint
| Qt::CustomizeWindowHint );

pirlogy
18th May 2011, 12:22
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.

pavanbarot
3rd August 2012, 14:27
I hope you want ready made code so please go thru below code.

//Code:
m_MainWindow->setWindowState( m_MainWindow->windowState() & (~Qt::WindowMinimized | Qt::WindowActiver));
Qt::WindowFlags windowFlags = (Qt::Dialog | Qt::CustomizeWindowHint);

if(bShowCloseOnly) //Show only close button
{
windowFlags |= Qt::WindowCloseButtonHint;
}
else //show only close and minimize button
{
windowFlags |= Qt::WindowMinimizeButtonHint;
windowFlags |= Qt::WindowCloseButtonHint;
}
m_MainWindow->setWindowFlags( windowFlags );
m_MainWindow->show();

Regards,

spirit
3rd August 2012, 14:36
Have you noticed that last post in this thread has been posted at 18th May 2011, 13:22 (more than one year ago)? :)