Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Still can resize the Window after setSizePolicy to fixed
Forum Updated to NodeBB v4.3 + New Features

Still can resize the Window after setSizePolicy to fixed

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 647 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hikaris
    wrote on last edited by
    #1

    Hi, here's the constructor of my MainWindow class. I set the window size policy to fixed, and updateGeometry, but still can resize the window. Why it can't work? Maybe I used it in a wrong way?

    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        this->updateGeometry();
    }
    
    1 Reply Last reply
    1
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      Size policy is a layout attribute. So it only takes effect in layouts.
      It will never have any effect on a window.
      If you don't want your window to be resized, you should use setFixedSize.

      H 1 Reply Last reply
      5
      • B Bonnie

        Size policy is a layout attribute. So it only takes effect in layouts.
        It will never have any effect on a window.
        If you don't want your window to be resized, you should use setFixedSize.

        H Offline
        H Offline
        hikaris
        wrote on last edited by
        #3

        @Bonnie Thank you ~

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved