Results 1 to 2 of 2

Thread: (SOLVED) About execution order for resize, move and show a hidden widget

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default (SOLVED) About execution order for resize, move and show a hidden widget

    Sometimes I have this problem ....
    I have this code to creat a custom widget:
    Qt Code:
    1. A_panel * my_class;
    2. my_classs = new a_panel(title, parent, sizable, modal);
    3. a_panel->resize(parent->width()*float(tam_100_or_0)/100, parent->height()*float(tam_100_or_0)/100);
    4. a_panel->w_center_on window(w_original,w_dest);
    5. // (w_original is or the a_panel itself or a dialog that owns it , w_dest is the main window or a dialog) (they are properly determined).
    6. a_panel->setVisible(true);
    To copy to clipboard, switch view to plain text mode 


    Ok, the w_center_on_window( QWidget* widget_dest, QWidget * widget) :
    Qt Code:
    1. widget->move((widget_dest->width()-widget->width())/2, (widget_dest->height()-widget->height())/2);
    To copy to clipboard, switch view to plain text mode 

    Ok, a_panel is hidden until I show it (A_panel->setvisible(true));
    The centered of widget using w_center_on_window does not work. This is because the widget is not visible ?
    If I change the order, it works (but I see a fast but annoying screenshot....
    a_panel->setVisible(true);[/CODE]
    a_panel->w_center_on window();

    Any help ? Thanks.
    Ups, excuse me ............
    If the widget is visible when it is being resized, it receives a resize event (resizeEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive an event before it is shown.
    Last edited by tonnot; 27th January 2012 at 09:27.

  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: (SOLVED) About execution order for resize, move and show a hidden widget

    If a widget was never shown, it won't "resize" nor "move". Changes will only be scheduled, not executed. If you are interested in the order itself then look into Qt source code, I would assume it uses setGeometry() which would resize and move at the same time.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 6
    Last Post: 19th September 2016, 11:44
  2. Replies: 4
    Last Post: 2nd October 2011, 00:20
  3. Libcurl messes up the order of execution
    By phoenix12345 in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2010, 11:14
  4. Execution order
    By Ishtar in forum Newbie
    Replies: 2
    Last Post: 26th April 2010, 20:36
  5. Move and resize with layout
    By waediowa in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2008, 08:16

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.