Results 1 to 10 of 10

Thread: Remove max,min button on a QMainWindow

  1. #1
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Remove max,min button on a QMainWindow

    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

  2. #2
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Remove max,min button on a QMainWindow

    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
    Qt Code:
    1. setWindowFlags(Qt::FramelessWindowHint);
    2. setWindowFlags(Qt::WindowTitleHint);
    3. setWindowTitle(tr("your title"));
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 16th July 2007 at 14:03. Reason: changed [html] to [code]

  3. #3
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove max,min button on a QMainWindow

    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

  4. #4
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Remove max,min button on a QMainWindow

    now you getting only minmize button or all buttons?
    try this, first you make flag 0 then you add only Qt::WindowTitleHint.
    Qt Code:
    1. Qt::WindowFlags flags = 0;
    2. flags |= Qt::FramelessWindowHint;// i think this not required
    3. flags |= Qt::WindowTitleHint;
    4. myWindow->setWindowFlags(flags);
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 16th July 2007 at 14:04. Reason: changed [html] to [code]

  5. #5
    Join Date
    Jul 2007
    Posts
    57
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove max,min button on a QMainWindow

    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.

  6. #6
    Join Date
    Jun 2007
    Posts
    28
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove max,min button on a QMainWindow

    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 Code:
    1. Qt::WindowFlags flags = roboteditvar->windowFlags();
    2. roboteditvar->move(pos);
    3. roboteditvar->setWindowFlags(flags & ~Qt::WindowContextHelpButtonHint);
    4. roboteditvar->show();
    To copy to clipboard, switch view to plain text mode 

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

    nowire

  7. #7
    Join Date
    Feb 2007
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Remove max,min button on a QMainWindow

    Qt Code:
    1. setWindowFlags( Qt::Window
    2. | Qt::WindowTitleHint
    3. | Qt::CustomizeWindowHint );
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Remove max,min button on a QMainWindow

    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.

  9. #9
    Join Date
    Jul 2010
    Location
    Ahmedabad,Gujarat,India
    Posts
    25
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Remove max,min button on a QMainWindow

    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:ialog | 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,

  10. #10
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Remove max,min button on a QMainWindow

    Have you noticed that last post in this thread has been posted at 18th May 2011, 13:22 (more than one year ago)?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Disabling the Maximize button in QMainWindow ?
    By sunil.thaha in forum Qt Programming
    Replies: 17
    Last Post: 26th June 2017, 14:31
  2. Remove restore button
    By vermarajeev in forum Qt Programming
    Replies: 3
    Last Post: 26th June 2007, 14:29
  3. Replies: 6
    Last Post: 21st February 2007, 21:35
  4. Replies: 2
    Last Post: 1st August 2006, 11:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.