Results 1 to 4 of 4

Thread: Infinite loop - resize parent from child

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Infinite loop - resize parent from child

    For this project i'm using Windows and Qt 4.1.2

    I have a QMainWindow that contains a widget that occupies the entire window. When the resizeEvent of the child widget is called I want the child to maintain proportions. After fixing the width/height proportions of the child I need to resize the parent.

    I've included a complete program that demonstrates the issue.

    Here is the wrong solution, but what would be a good workaround for it?

    Qt Code:
    1. void MyWidget::resizeEvent(QResizeEvent* event)
    2. {
    3. QSize newsz = event->size();
    4.  
    5. _figureHeight = newsz.width()*_figureHeight/_figureWidth;
    6. _figureWidth = newsz.width();
    7.  
    8. parentWidget()->resize(_figureWidth, _figureHeight);
    9. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

Similar Threads

  1. connecting child to parent window...
    By sumit in forum Qt Programming
    Replies: 1
    Last Post: 19th October 2008, 21:28
  2. How to close parent window from child window?
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2008, 11:40
  3. Move child widget along with the parent widget
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:00
  4. Referencing Parent Widget from Child
    By taylor34 in forum Qt Programming
    Replies: 8
    Last Post: 11th April 2006, 15:13

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.