سؤال

When trying to set a fixed window size why doesn't the following code work:

window->setSizeIncrement(1024,600);
window->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);

But this code does:

window->setMaximumHeight(600);
window->setMinimumHeight(600);
window->setMaximumWidth(1024);
window->setMinimumWidth(1024);

I achieve what I want, a fixed width and height window. Not as efficiently as I had thought.

هل كانت مفيدة؟

المحلول

You could simply use setFixedSize(const QSize & s) to achieve the same.

As for the setsizeIncrement(), as discussed in the documentation it merely sets an increment step for the window size. What's more, depending on your platform the following might be important:

Warning: The size increment has no effect under Windows, and may be disregarded by the window manager on X11.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top