Results 1 to 14 of 14

Thread: ResizeEvent/Resize out of control

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: ResizeEvent/Resize out of control

    oh, i've run in a little problem: the images seem to only show up after resizing the whole window. i tried to manually resize it (same code like in paintEvent) but that doesn't work

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

    Default Re: ResizeEvent/Resize out of control

    Yes, of course, my bad. If you call setPixmap() before show() is called, recalculate() will calculate the new pixmap based on incorrect width and height of the widget (although it's a bit strange as the showEvent should trigger a resizeEvent). You can reimplement showEvent() and call recalculate() and update() there and everything should be fine. The widget will repaint itself twice, but that's a minor problem as one of the runs will return immediately. If you want to fix it, you should for example assign m_px to m_scaled in setPixmap and set the margins to 0 instead of calling recalculate(). If the size hint of the widget is kept, the image will be fine.

  3. #3
    Join Date
    Jan 2008
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: ResizeEvent/Resize out of control

    At the moment, i have no idea what update does Qt tells me:
    Quote Originally Posted by Qt 4.4
    Widget painting can only begin as a result of a paintEvent
    Thats cause i just used the same code in update as for paintEvent

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

    Default Re: ResizeEvent/Resize out of control

    You don't implement update, you call it and Qt schedules a paintEvent. You were to implement showEvent() and call recalculate() and update() there.

    Qt Code:
    1. void xxx:showEvent(QShowEvent *e){
    2. recalculate();
    3. update();
    4. QWidget::showEvent(e);
    5. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2008
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: ResizeEvent/Resize out of control

    i'm sorry, i just found functions that expected some parameters, is missed the normal QWidget::update() :-)
    In one place where i have two instanced in a tab widget as individual tabs, there is now the problem that after the images load, the widgets resize to nearly the full size of the image rather than to the size of the widget. But except that, it works. Thank you :-)

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

    Default Re: ResizeEvent/Resize out of control

    You probably forgot to apply some of the layouts.

  7. #7
    Join Date
    Jan 2008
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: ResizeEvent/Resize out of control

    not directly layouts I felt the power of QSizePolicy:
    not the tab widget itself, but the objects that show the images need a policy:
    Qt Code:
    1. screen1->setSizePolicy ( QSizePolicy::Ignored, QSizePolicy::Ignored );
    2. screen2->setSizePolicy ( QSizePolicy::Ignored, QSizePolicy::Ignored );
    To copy to clipboard, switch view to plain text mode 
    hehe, again, thank you very much. As everything works well (and now, the images show up immediatly in the tabWidget instead of needing 7 seconds to load without sizePolicys), i'm very happy that the program is finally finished (my biggest program ever).

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

    Default Re: ResizeEvent/Resize out of control

    No, certainly Ignored is not needed. If you think you need it, you must have done something Bad. I've been programming Qt for more than 4 years and I never needed to set the size policy to ignored

  9. #9
    Join Date
    Jan 2008
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: ResizeEvent/Resize out of control

    Hm... then i may be on the wrong path in general when making GUIs.
    If you have some time, could you please have a look at what i did to make the gui? The files are here:
    Base to the vcs.
    The GUI-Files are BinaryViewer.cpp, BinaryViewer.h, ImageViewer.cpp, ImageViewer.h. There are some others, but they have no real GUI but provide a simple Stack that shows the actual GUIs.
    Thanks, C167

Similar Threads

  1. Replies: 3
    Last Post: 7th October 2015, 20:43
  2. Text shifts when control appears...
    By MrGarbage in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2008, 04:12
  3. Version control - what to use?
    By TheKedge in forum General Programming
    Replies: 11
    Last Post: 4th March 2007, 09:49
  4. QTextEdit control
    By vijay anandh in forum Qt Programming
    Replies: 2
    Last Post: 31st May 2006, 14:14
  5. Replies: 6
    Last Post: 3rd February 2006, 10:48

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
  •  
Qt is a trademark of The Qt Company.