tonnot
27th January 2012, 08:57
Sometimes I have this problem ....
I have this code to creat a custom widget:
A_panel * my_class;
my_classs = new a_panel(title, parent, sizable, modal);
a_panel->resize(parent->width()*float(tam_100_or_0)/100, parent->height()*float(tam_100_or_0)/100);
a_panel->w_center_on window(w_original,w_dest);
// (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).
a_panel->setVisible(true);
Ok, the w_center_on_window( QWidget* widget_dest, QWidget * widget) :
widget->move((widget_dest->width()-widget->width())/2, (widget_dest->height()-widget->height())/2);
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.
I have this code to creat a custom widget:
A_panel * my_class;
my_classs = new a_panel(title, parent, sizable, modal);
a_panel->resize(parent->width()*float(tam_100_or_0)/100, parent->height()*float(tam_100_or_0)/100);
a_panel->w_center_on window(w_original,w_dest);
// (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).
a_panel->setVisible(true);
Ok, the w_center_on_window( QWidget* widget_dest, QWidget * widget) :
widget->move((widget_dest->width()-widget->width())/2, (widget_dest->height()-widget->height())/2);
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.