Important: Please read the Qt Code of Conduct -

QVBoxLayout::setStretchFactor dosen't work

  • 0_1527130400188_QQ截图20180524045110.png

    I have set the stretch-factor of two layouts, why it dosen't work?

  • Moderators

    @Limer Those stretch factors are nowhere near being realized in that size of a window. With a 1 you are saying basically you want a minimum widget stretch of 1 and the other is 4. Your window is so big that these would be nowhere near being used. It looks like it's behaving as expected.

    What exactly are you trying to do? There's probably another way to go about what you are wanting. My guess is you are trying to compress the QLabels so they appear in a tight single spaced section ... if that's the case you just need to add column stretches, i.e. gLayout1->setColumnStretch(0,1); and gLayout1->setColumnStretch(1,1);. I'm guessing a bit here, I very rarely use grid layouts much preferring vbox and hbox to form up my "grid".

Log in to reply