PDA

View Full Version : resize window using a button



sachinmcajnu
19th April 2011, 18:24
i made a sort dialog and created two group boxes with some combox box inside and a more button
which hides the second group box on click of more button but the size of window remains the same
after gettting hidden ............how can the window be resized after second box is hidden
plz guide

produktdotestow
19th April 2011, 21:16
Check out

void QWidget::resize(const QSize &)
void QWidget::setMinimumSize(const QSize &)
void QWidget::setMaximumSize(const QSize &)

methods.

sachinmcajnu
20th April 2011, 06:27
Check out

void QWidget::resize(const QSize &)
void QWidget::setMinimumSize(const QSize &)
void QWidget::setMaximumSize(const QSize &)

methods.

thanks for the reply.............
but how to do it in qt designer

produktdotestow
21st April 2011, 14:52
Have you ever heard about signals and slots mechanism? Create slot, where you'll call one of those methods and connect it to clicked() signal.

Let's say that your button is named "pushButton1" and your window class name is "Window"

window.h

(...)
protected slots:
void resizeWindow();
(...)

window.cpp

Window::Window(...)
{
(...)
connect(ui->pushButton1, SIGNAL(clicked()), this, SLOT(resizeWindow()));
(...)
}

void Window::resizeWindow(){
/* here do what you want
this->resize(QSize(x, y));
for example */
}