tags:

views:

2592

answers:

5

I have a QT dialog application. Now I dont want that dialog to be resizeable. I am not sure how to achieve this. I tried a bunch of things but still when the dialog launches this dialog can be resized.

What is the property that i should set to disable the dialog/Widget resize.

I also tried

setSizePolicy(QSizePolicy::Fixed);

But i get an error saying..

source\nimcac_settingsMain.cpp(36) : error C2248:
**'QSizePolicy::QSizePolicy' : cannot access private member declared in class 'QSizePolicy'**
        p:\ThirdPartyExports\Qt\export\4.3\4.3.1f14\include\QtGui\../../src\gui\
kernel\qsizepolicy.h(177) : see declaration of 'QSizePolicy::QSizePolicy'
        p:\ThirdPartyExports\Qt\export\4.3\4.3.1f14\include\QtGui\../../src\gui\
kernel\qsizepolicy.h(34) : see declaration of 'QSizePolicy'

Kindly help me out with this.

Regards, Arjun

+1  A: 

You need to change the windowFlags of the dialog and set it to Qt::MSWindowsFixedSizeDialogHint.

This only works in windows.

For more information please see this example: http://doc.trolltech.com/4.5/widgets-windowflags.html

xgoan
+5  A: 

I don't know if you already tried it, but QWidget::setFixedSize should do what you want

Caotic
A: 

I hope you pretty much got your answer in case looking for something more do let know as I have this workin for me on windows system.

+4  A: 

The compile error you get is because you try to pass a QSizePolicy::Policy to setSizePolicy(QSizePolicy), but there's no implicit conversion from QSizePolicy::Policy (which is the policy for one dimension) to QSizePolicy (which is a class containing, among other things, one Policy per dimension (height, width)). QSizePolicy doesn't work on top-level widgets (windows) anyway, though.

setFixedSize() only works if you know the size of the dialog in advance (and usually you don't, what with changing font sizes and languages). You can do

window()->setFixedSize( window->sizeHint() );

but it's much better to use

window->layout()->setSizeConstraint( QLayout::SetFixedSize );

That lets the layout determine the size of the dialog, but doesn't allow resizing, which I assume is what you were asking for.

+2  A: 

this->setFixedSize(this->width(),this->height());

Samir