shock
11th December 2011, 11:46
Hey,
I have troubles on replacing items on resizeEvent of the QMainWindow - I am not using any layout, i just recalculate the new positions on resize.
If the window is resized slowly there are not any troubles but if i resize it very fast by moving the mouse in crazy ways i get weird results....
I added a "before resize" and a "after resize" screenshot to illustrate the problem.
The Code looks like follows:
void ClientMainWindow::resizeEvent(QResizeEvent * event){
int heightPositionCorrection = (event->size().height()-event->oldSize().height())/2;
int widthPositionCorrection = (event->size().width()-event->oldSize().width())/2;
ui.controlAirCondition->setGeometry(
ui.controlAirCondition->geometry().x()+widthPositionCorrection,
ui.controlAirCondition->geometry().y()+heightPositionCorrection,
ui.controlAirCondition->geometry().width(),ui.controlAirCondition->geometry().height());
ui.controlAlarmSystem->setGeometry(
ui.controlAlarmSystem->geometry().x()+widthPositionCorrection,
ui.controlAlarmSystem->geometry().y()+heightPositionCorrection,
ui.controlAlarmSystem->geometry().width(),ui.controlAlarmSystem->geometry().height());
ui.controlBlinds->setGeometry(
ui.controlBlinds->geometry().x()+widthPositionCorrection,
ui.controlBlinds->geometry().y()+heightPositionCorrection,
ui.controlBlinds->geometry().width(),ui.controlBlinds->geometry().height());
ui.controlHeating->setGeometry(
ui.controlHeating->geometry().x()+widthPositionCorrection,
ui.controlHeating->geometry().y()+heightPositionCorrection,
ui.controlHeating->geometry().width(),ui.controlHeating->geometry().height());
ui.controlLights->setGeometry(
ui.controlLights->geometry().x()+widthPositionCorrection,
ui.controlLights->geometry().y()+heightPositionCorrection,
ui.controlLights->geometry().width(),ui.controlLights->geometry().height());
ui.controlMusic->setGeometry(
ui.controlMusic->geometry().x()+widthPositionCorrection,
ui.controlMusic->geometry().y()+heightPositionCorrection,
ui.controlMusic->geometry().width(),ui.controlMusic->geometry().height());
ui.controlVideo->setGeometry(
ui.controlVideo->geometry().x()+widthPositionCorrection,
ui.controlVideo->geometry().y()+heightPositionCorrection,
ui.controlVideo->geometry().width(),ui.controlVideo->geometry().height());
ui.configScreen->setGeometry(
ui.configScreen->geometry().x()+widthPositionCorrection,
ui.configScreen->geometry().y()+heightPositionCorrection,
ui.configScreen->geometry().width(),ui.configScreen->geometry().height());
ui.controlPlaceholder->setGeometry(
ui.controlPlaceholder->geometry().x()+widthPositionCorrection,
ui.controlPlaceholder->geometry().y()+heightPositionCorrection,
ui.controlPlaceholder->geometry().width(),ui.controlPlaceholder->geometry().height());
}
71657166
What am i doing wrong here?
I have troubles on replacing items on resizeEvent of the QMainWindow - I am not using any layout, i just recalculate the new positions on resize.
If the window is resized slowly there are not any troubles but if i resize it very fast by moving the mouse in crazy ways i get weird results....
I added a "before resize" and a "after resize" screenshot to illustrate the problem.
The Code looks like follows:
void ClientMainWindow::resizeEvent(QResizeEvent * event){
int heightPositionCorrection = (event->size().height()-event->oldSize().height())/2;
int widthPositionCorrection = (event->size().width()-event->oldSize().width())/2;
ui.controlAirCondition->setGeometry(
ui.controlAirCondition->geometry().x()+widthPositionCorrection,
ui.controlAirCondition->geometry().y()+heightPositionCorrection,
ui.controlAirCondition->geometry().width(),ui.controlAirCondition->geometry().height());
ui.controlAlarmSystem->setGeometry(
ui.controlAlarmSystem->geometry().x()+widthPositionCorrection,
ui.controlAlarmSystem->geometry().y()+heightPositionCorrection,
ui.controlAlarmSystem->geometry().width(),ui.controlAlarmSystem->geometry().height());
ui.controlBlinds->setGeometry(
ui.controlBlinds->geometry().x()+widthPositionCorrection,
ui.controlBlinds->geometry().y()+heightPositionCorrection,
ui.controlBlinds->geometry().width(),ui.controlBlinds->geometry().height());
ui.controlHeating->setGeometry(
ui.controlHeating->geometry().x()+widthPositionCorrection,
ui.controlHeating->geometry().y()+heightPositionCorrection,
ui.controlHeating->geometry().width(),ui.controlHeating->geometry().height());
ui.controlLights->setGeometry(
ui.controlLights->geometry().x()+widthPositionCorrection,
ui.controlLights->geometry().y()+heightPositionCorrection,
ui.controlLights->geometry().width(),ui.controlLights->geometry().height());
ui.controlMusic->setGeometry(
ui.controlMusic->geometry().x()+widthPositionCorrection,
ui.controlMusic->geometry().y()+heightPositionCorrection,
ui.controlMusic->geometry().width(),ui.controlMusic->geometry().height());
ui.controlVideo->setGeometry(
ui.controlVideo->geometry().x()+widthPositionCorrection,
ui.controlVideo->geometry().y()+heightPositionCorrection,
ui.controlVideo->geometry().width(),ui.controlVideo->geometry().height());
ui.configScreen->setGeometry(
ui.configScreen->geometry().x()+widthPositionCorrection,
ui.configScreen->geometry().y()+heightPositionCorrection,
ui.configScreen->geometry().width(),ui.configScreen->geometry().height());
ui.controlPlaceholder->setGeometry(
ui.controlPlaceholder->geometry().x()+widthPositionCorrection,
ui.controlPlaceholder->geometry().y()+heightPositionCorrection,
ui.controlPlaceholder->geometry().width(),ui.controlPlaceholder->geometry().height());
}
71657166
What am i doing wrong here?