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. Why does the child widget not resize when I call resize () on parent?
Forum Updated to NodeBB v4.3 + New Features

Why does the child widget not resize when I call resize () on parent?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.6k Views 1 Watching
  • 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.
  • X Offline
    X Offline
    xruck
    wrote on last edited by
    #1

    There is CurveWidgetDialog derived form QDialog and QWidget curveWidget as child (attached picture).0_1547563547966_ыыы.png

    I call method resize() in constructor of CurveWidgetDialog, but child widget ()curveWidget doesn't change size (qDebug() outputs "QSize(100, 30)"). I use folowing code:

    CurveWidgetDialog::CurveWidgetDialog(QWidget *parent) :
    	QDialog(parent),
    	ui(new Ui::CurveWidgetDialog)
    {
    	ui->setupUi(this);
    //...
    	resize(1000, 1000);
    
    	qDebug() << ui->curveWidget->size();
    //...
    }
    

    what the hell?

    JonBJ 1 Reply Last reply
    0
    • X xruck

      There is CurveWidgetDialog derived form QDialog and QWidget curveWidget as child (attached picture).0_1547563547966_ыыы.png

      I call method resize() in constructor of CurveWidgetDialog, but child widget ()curveWidget doesn't change size (qDebug() outputs "QSize(100, 30)"). I use folowing code:

      CurveWidgetDialog::CurveWidgetDialog(QWidget *parent) :
      	QDialog(parent),
      	ui(new Ui::CurveWidgetDialog)
      {
      	ui->setupUi(this);
      //...
      	resize(1000, 1000);
      
      	qDebug() << ui->curveWidget->size();
      //...
      }
      

      what the hell?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @xruck
      I assume the reason is: What size settings do you have on your CurveWidget which tell it you'd like it to occupy the full size of its parent QDialog?

      Otherwise: It's just possible that resizing in the parent's constructor is too early for the child, though I don't think so.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xruck
        wrote on last edited by
        #3

        0_1547566542594_ыыыы.PNG
        Do you mean sizePolicy?

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          Hi
          Some layout calculation is postponed until widget is shown meaning
          qDebug() << ui->curveWidget->size(); in constructor does not show the new size values.

          So does it visually also NOT use all the space ?
          When CurveWidgetDialog is actually shown on screen.

          X 1 Reply Last reply
          1
          • mrjjM mrjj

            Hi
            Some layout calculation is postponed until widget is shown meaning
            qDebug() << ui->curveWidget->size(); in constructor does not show the new size values.

            So does it visually also NOT use all the space ?
            When CurveWidgetDialog is actually shown on screen.

            X Offline
            X Offline
            xruck
            wrote on last edited by
            #5

            @mrjj
            I create and show dialog in the main.cpp

            int main(int argc, char *argv[])
            {
            	QApplication a(argc, argv);
            
            	CurveWidgetDialog w;
            	w.show();
            
            	return a.exec();
            }
            

            I suppose I need handle QWidget::showEvent() signal to recive size of the widget?

            mrjjM 1 Reply Last reply
            0
            • X xruck

              @mrjj
              I create and show dialog in the main.cpp

              int main(int argc, char *argv[])
              {
              	QApplication a(argc, argv);
              
              	CurveWidgetDialog w;
              	w.show();
              
              	return a.exec();
              }
              

              I suppose I need handle QWidget::showEvent() signal to recive size of the widget?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @xruck
              Yes showEvent should give true size.
              So it does use the actual space when shown, and its just the size reporting that is off ?

              X 1 Reply Last reply
              0
              • mrjjM mrjj

                @xruck
                Yes showEvent should give true size.
                So it does use the actual space when shown, and its just the size reporting that is off ?

                X Offline
                X Offline
                xruck
                wrote on last edited by JKSH
                #7

                @mrjj Yeah! Fantasstic answer!! Thank you very much!:) We close question [EDIT: Expletives removed --JKSH]

                1 Reply Last reply
                -1

                • Login

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