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. Qwidget's size not get updated ?
Forum Update on Monday, May 27th 2025

Qwidget's size not get updated ?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 153 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.
  • J Offline
    J Offline
    junzhe fan
    wrote on last edited by junzhe fan
    #1

    Hi, I got a custom QWidget, then I set it as my QMainWindow's menubar using setMenuWidget, but the width was not get updated as I assumed it should be the same as the width of the Mainwindow, the statusBar also has the same issue as well, but both of them look stretched out to align with the Width of my MainWindow , thanks for the help!

        TitleBar = new CustomizedTitleBar(this);
        this->setWindowFlags(Qt::FramelessWindowHint);
        this->setMenuWidget(TitleBar);
        qDebug()<<TitleBar->width()<<TitleBar->parentWidget()->width();
                   //prints 453               /prints 1200
    
    JonBJ 1 Reply Last reply
    0
    • J junzhe fan

      Hi, I got a custom QWidget, then I set it as my QMainWindow's menubar using setMenuWidget, but the width was not get updated as I assumed it should be the same as the width of the Mainwindow, the statusBar also has the same issue as well, but both of them look stretched out to align with the Width of my MainWindow , thanks for the help!

          TitleBar = new CustomizedTitleBar(this);
          this->setWindowFlags(Qt::FramelessWindowHint);
          this->setMenuWidget(TitleBar);
          qDebug()<<TitleBar->width()<<TitleBar->parentWidget()->width();
                     //prints 453               /prints 1200
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @junzhe-fan said in Qwidget's size not get updated ?:

      but both of them look stretched out to align with the Width of my MainWindow

      So are you saying they do appear correctly?

      Printing out widget widths/heights e.g. just after creating them does not deliver meaningful results. Dimensions only get set correctly after a widget has been shown, as that is when Qt calculates them.

      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