Results 1 to 6 of 6

Thread: Resizing the dialog box dynamically

  1. #1
    Join Date
    Jun 2006
    Location
    India
    Posts
    14
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Resizing the dialog box dynamically

    hi ,

    I am new to QT.., my problem is can we resize the dialog dynamically,

    i.e, using any controls, Say for eg slider, can we resize the dialog when the slider is moved

    thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Resizing the dialog box dynamically

    Yes, of course. You have to connect the slider's valueChanged signal to a custom slot which will resize() the dialog.

  3. The following user says thank you to wysota for this useful post:

    vvbkumar (14th June 2006)

  4. #3
    Join Date
    Jun 2006
    Location
    India
    Posts
    14
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Resizing the dialog box dynamically

    hi
    i have tried using resize(), but its not effecting on the dialog box???

    can u pl help me out.

    thanks in advance,
    Last edited by vvbkumar; 19th June 2006 at 09:52.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Resizing the dialog box dynamically

    Can you show some code you wrote for that?

  6. #5
    Join Date
    Jun 2006
    Location
    India
    Posts
    14
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Exclamation Re: Resizing the dialog box dynamically

    here is the code :

    Qt Code:
    1. int main (int argc, char *argv[]){
    2. QApplication app(argc, argv);
    3. QDialog *dialog = new QDialog();
    4. QHBox *hbox = new QHBox;
    5. hbox->setCaption("Slider is at : ");
    6. hbox->setMargin(6);
    7. hbox->setSpacing(6);
    8. QSpinBox *spinbox = new QSpinBox(hbox);
    9. QSlider *slider = new QSlider(Qt::Horizontal, hbox);
    10. spinbox->setRange(0,100);
    11. slider->setRange(0,100);
    12. QObject::connect(spinbox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
    13. QObject::connect(slider, SIGNAL(valueChanged(int)), spinbox, SLOT(setValue(int)));
    14. int x = spinbox->value();
    15. int y = slider->value();
    16. hbox->resize(x,y);
    17. spinbox->setValue(11);
    18. app.setMainWidget(hbox);
    19. hbox->show();
    20. return app.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 20th June 2006 at 09:41. Reason: Added [code] tags

  7. #6
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resizing the dialog box dynamically

    This only resizes the dialog to the initial state (i.e. 0 by 0 pixels). You've also interconnected the slider and the spin box. You need to subclass the dialog and create two slots - setX and setY which you then connect to the slider and spinbox.

Similar Threads

  1. Show/hide part of dialog with resizing.
    By Spockmeat in forum Qt Tools
    Replies: 6
    Last Post: 7th June 2006, 08:22
  2. Problem with resizing dialog
    By Seema Rao in forum Qt Programming
    Replies: 8
    Last Post: 5th May 2006, 17:27
  3. Dialog positioning in GNOME
    By simk in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2006, 09:41
  4. Shape-changing dialog with qt4.1
    By moe in forum Qt Tools
    Replies: 3
    Last Post: 2nd February 2006, 10:12
  5. Dynamically resizing in QT 3
    By kroenecker in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2006, 18:37

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.