Results 1 to 3 of 3

Thread: Qwidget resize delay problem

  1. #1
    Join Date
    Sep 2008
    Posts
    23
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question Qwidget resize delay problem

    hi, there
    I am using the qwidget to display images which could be portrait or landscape and the widget is resized for the image size, everything looks fine except when I display a portrait after a landscape or vise versa , the widget becomes square. A second image of the same shape will turn the widget to the image's shape. For example, if I am showing portrait, landscape, landscape in a sequence, the widget will be portrait, square, landscape. How can I change the square to the shape of the image? Here is my code.

    Qt Code:
    1. /* imageLabel, imageviewerLayout, and imageViewer are QLabel, QVBoxLayout and QWidget which are defined globally*/
    2. QImage image(myFileName);
    3. imageLabel->setPixmap(QPixmap::fromImage(image));
    4. imageLabel->resize(image.size());
    5. imageviewerLayout->update();
    6. imageViewer->resize(image.size());
    7. imageViewer->updateGeometry();
    8. imageViewer->show();
    To copy to clipboard, switch view to plain text mode 

    Thanks for help and have a good weekend.
    zl2k

  2. #2
    Join Date
    Aug 2008
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwidget resize delay problem

    Hi,

    you can try QWidget::adjustSize()

    or

    on portrait or landscape you r getting some signal, in its slot get the size of the image and set that size to QWidget.

    Hope it will help.

  3. #3
    Join Date
    Sep 2008
    Posts
    23
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qwidget resize delay problem

    Qt Code:
    1. imageViewer->resize(image.size());
    2. //imageViewer->updateGeometry();
    3. imageViewer->adjustSize();
    To copy to clipboard, switch view to plain text mode 
    will do the job. If the updateGeometry() is there, it will still adjust the portrait/landscape. But, if I am showing a 400*200 after a 400*300 (both landscape), the size of the widget wont't be adjusted immediately. I still need a second 400*200. After removing the updateGeometry(), everything works fine now, thank you.
    zl2k

Similar Threads

  1. Replies: 1
    Last Post: 10th August 2008, 18:55
  2. QGLWidget Resize Problem
    By Sandip in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2008, 06:47
  3. QGLWidget resize problem.
    By anderl in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2008, 08:57
  4. Resize QWidget in QMainWindow
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 8th March 2007, 12:16
  5. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 22:59

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.