Results 1 to 3 of 3

Thread: setFixedSize() not working

  1. #1
    Join Date
    May 2012
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default setFixedSize() not working

    I tried using
    Qt Code:
    1. QWidget::setFixedSize(463, 251);
    To copy to clipboard, switch view to plain text mode 
    but when I run my program it's still resizable. I also tried different things like setting the minimumSize and maximumSize and changing the sizePolicy to fixed but the result is still the same.

    I attached the file for reference.
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: setFixedSize() not working

    It would help if you attached source files rather of a complete example rather than an intermediate like the ui_*h file.

    There's nothing in that ui*h file that would stop the main window from resizing. Using setFixedsize() on the QMainWindow certainly works here:
    Qt Code:
    1. #include <QApplication>
    2. #include "ui_mainwindow.h" // your file as delivered
    3.  
    4. namespace Ui {
    5. class MainWindow;
    6. };
    7.  
    8. class MainWindow: public QMainWindow
    9. {
    10. Q_OBJECT
    11. public:
    12. MainWindow(QWidget *p = 0): QMainWindow(p), ui(new Ui::MainWindow) {
    13. ui->setupUi(this);
    14. }
    15. private:
    16. Ui::MainWindow *ui;
    17. };
    18.  
    19. int main(int argc, char *argv[])
    20. {
    21. QApplication a(argc, argv);
    22. MainWindow w;
    23. w.show();
    24. w.setFixedSize(463, 251);
    25. a.exec();
    26. }
    27. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    Since you have use absolute positioning and not used layouts the contents and the container are essentially independent and you forgo much control. The push buttons and edit boxes you placed with Designer are not moving with the widget that contains them as your QMainWindow is resizing it.

  3. #3
    Join Date
    May 2012
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setFixedSize() not working

    Thanks totally work!!!

Similar Threads

  1. Show/Hide height animation with SetFixedSize
    By mnunberg in forum Qt Programming
    Replies: 7
    Last Post: 24th November 2010, 11:11
  2. Resize of main window without setFixedSize
    By ElyBeta in forum Qt Programming
    Replies: 2
    Last Post: 15th July 2010, 15:09
  3. MVC example not working
    By yyiu002 in forum Newbie
    Replies: 1
    Last Post: 30th June 2010, 00:07
  4. Docking widgets setFixedSize and setBaseSize Problem
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 16th October 2006, 18:20
  5. setFixedSize
    By raphaelf in forum Qt Programming
    Replies: 3
    Last Post: 22nd February 2006, 11:32

Tags for this Thread

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.