[Qt-interest] resizeEvent get's only called _after_ resize

Oliver Demetz forenbeitraege at oliverdemetz.de
Sun Jul 19 19:11:55 CEST 2009


Hi!

I think you just got a small error in your code:


Christoph Fritz schrieb:
> [snip] 
> In the constructor I did:
>   MainWindow::MainWindow(QWidget *parent)
>       : QMainWindow(parent), ui(new Ui::MainWindow)
>   {
>       ui->setupUi(this);
>       this->sizePolicy().setHeightForWidth(true);
>   }
> 

This should be
MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent), ui(new Ui::MainWindow)
{
        ui->setupUi(this);
        QSizePolicy p = this->sizePolicy();
        p.setHeightForWidth(true);
        this->setSizePolicy(p);
}

because QWidget::sizePolicy() just returns a copy of its size policy, 
not a reference.

I'm not sure whether that was the only bug in your code but I hope it 
helps. Please be so kind to report when you got the code working.

Regards,
Oliver



More information about the Qt-interest-old mailing list