Results 1 to 4 of 4

Thread: resize window using a button

  1. #1
    Join Date
    Mar 2011
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default resize window using a button

    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

  2. #2
    Join Date
    Feb 2010
    Location
    Poland
    Posts
    27
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: resize window using a button

    Check out
    Qt Code:
    1. void QWidget::resize(const QSize &)
    2. void QWidget::setMinimumSize(const QSize &)
    3. void QWidget::setMaximumSize(const QSize &)
    To copy to clipboard, switch view to plain text mode 

    methods.

  3. #3
    Join Date
    Mar 2011
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: resize window using a button

    Quote Originally Posted by produktdotestow View Post
    Check out
    Qt Code:
    1. void QWidget::resize(const QSize &)
    2. void QWidget::setMinimumSize(const QSize &)
    3. void QWidget::setMaximumSize(const QSize &)
    To copy to clipboard, switch view to plain text mode 

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

  4. #4
    Join Date
    Feb 2010
    Location
    Poland
    Posts
    27
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: resize window using a button

    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
    Qt Code:
    1. (...)
    2. protected slots:
    3. void resizeWindow();
    4. (...)
    To copy to clipboard, switch view to plain text mode 

    window.cpp
    Qt Code:
    1. Window::Window(...)
    2. {
    3. (...)
    4. connect(ui->pushButton1, SIGNAL(clicked()), this, SLOT(resizeWindow()));
    5. (...)
    6. }
    7.  
    8. void Window::resizeWindow(){
    9. /* here do what you want
    10.  this->resize(QSize(x, y));
    11.  for example */
    12. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 23rd December 2010, 06:55
  2. Replies: 0
    Last Post: 10th September 2010, 13:23
  3. Resize button when using layout
    By Macok in forum Qt Tools
    Replies: 3
    Last Post: 26th January 2009, 00:31
  4. How to resize a Button
    By Walsi in forum Newbie
    Replies: 3
    Last Post: 2nd April 2008, 01:08
  5. Maximize Window button of Manin Window
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 1st August 2007, 08:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.