Results 1 to 2 of 2

Thread: How do I prevent the user from resizing the application window?

  1. #1
    Join Date
    Aug 2010
    Posts
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How do I prevent the user from resizing the application window?

    Well since I've been searching for a clear answer on this and didn't find it easy to figure out how to do it, anyway, I hope this will help someone in the future.

    So if you want to prevent the window from being resized, let it be QWidget or QDialog or QMainWindow, well for me this worked:

    Just type in this line in the constructor:

    this->setFixedSize(this->size().width(), this->size().height());

    Or you can just specify a different size obtained from variables... But that's how it perfectly worked for me, for all my dialogs.

    Just another example of how to use it:

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. this->setFixedSize(this->size().width(), this->size().height());
    7. }
    To copy to clipboard, switch view to plain text mode 

    Hope this is going to be useful for people searching for this in the future.

  2. The following user says thank you to arcelivez for this useful post:

    jonthom (22nd October 2010)

  3. #2
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How do I prevent the user from resizing the application window?

    Yes, the fixed size is a bit hidden. :P Such things you can post to the wiki, because your topic will move on and because the search engine of the forum is a bit buggy(at last for me) it will be easier for the users to find this info in to the wiki.

Similar Threads

  1. Replies: 3
    Last Post: 2nd March 2010, 20:58
  2. Prevent a QLabel resizing the parent QWidget
    By danc81 in forum Qt Programming
    Replies: 6
    Last Post: 10th November 2009, 20:54
  3. QSpitter - prevent resizing
    By jonks in forum Newbie
    Replies: 3
    Last Post: 28th July 2009, 19:36
  4. how to prevent QGraphicsView() resizable by user
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 24th February 2009, 14:47
  5. Prevent from resizing a QMainWindow
    By Flier in forum Qt Tools
    Replies: 5
    Last Post: 14th April 2006, 17:11

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.