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. How to resize the main window again after setFixedSize
Forum Update on Monday, May 27th 2025

How to resize the main window again after setFixedSize

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.4k 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.
  • C Offline
    C Offline
    CorD SaC
    wrote on last edited by
    #1

    In my code I set fixed size for main window If i open .mp3 file,now I need to resize main window if i open another file format. how to enable resize if I open any other file format

    this is my code.

    void MainWindow::on_actionOpen_triggered()
    {
      QString filename= QFileDialog::getOpenFileName(this,"Open Folder","","Open a File(*.*)");
      on_actionStop_triggered();
       player->setMedia(QUrl::fromLocalFile(filename));
       on_actionPlay_triggered();
    
        if(filename.endsWith(".mp3")){
            qDebug() << " file is mp3";
            this->setFixedSize(648,425);
    
        }else{
            this->setFixedSize(this->sizeHint()); //this not working. 
        }
    }
    
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      It does work. check your values :)

      just tested this

      ctor
      {
        ui->setupUi(this);
        setFixedSize(300,300);
      }
      
      
      void MainWindow::on_pushButton_released()
      {
          setFixedSize(500,500);
      }
      
      

      and it goes to 500x500 when i click

      1 Reply Last reply
      1
      • C Offline
        C Offline
        CorD SaC
        wrote on last edited by
        #3

        According to your code If I set like this setFixedSize(500,500); form resize 500x500 but I need to resize my mainwindow using mouse as a default way

        1 Reply Last reply
        0
        • S Offline
          S Offline
          samdol
          wrote on last edited by
          #4

          Why don't you use resize(int w, int h) function instead of setFixedSize(w,h) at the first place?

          1 Reply Last reply
          2

          • Login

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