Unsolved Resizing mainwindow using resizeEvent works very slow
-
@kshegunov said:
@soloespresso
No one is preventing you from callingcalculatedXY()
, but if it's a good design choice really depends what that function actually does.Thank you for the confirmation.
Because calling drawPath() will call readPosition(), calculatedXY() and writePosition(), calling calculatedXY() directly will prevent resizeEvent() to reread the text file.But this give me that Runtime Error and "index out of range" which I will debug later.
Now the problem is how to draw the line? I use paintEvent() to draw a line and the function is called when drawPath() is called.
-
"Now the problem is how to draw the line?" - what is the problem with that? When paintEvent() is called you draw the line.
-
@jsulm said:
"Now the problem is how to draw the line?" - what is the problem with that? When paintEvent() is called you draw the line.
But then it means paintEvent() is called directly in resizeEvent()?
Is something like the code below possible?void MainWindow::resizeEvent(QResizeEvent *event) { //scaled window size scaledWidth = double(event->size().width())/360.0; scaledHeight = double(event->size().height())/180.0; //QString inFile = ":/input.txt"; //QString outFile = "output.txt"; //set label window size ui->label->setGeometry(0, 0, 360*scaledWidth, 180*scaledHeight); //set draworbit window size //path->drawPath(inFile, outFile, scaledWidth, scaledHeight); path->calculatedXY(someVector, scaledWidth, scaledHeight); path->paintEvent(); path->setGeometry(0, 0, 360*scaledWidth, 180*scaledHeight); }
-
No, paintEvent() is called by Qt whenever a repaint is needed.
For example it is called after resizing a widget (as stated in documentation). -
@jsulm ok. sorry for a dumb question. I have tried it before but it didn't work so I wasn't sure if I understand how it works correctly.
So I tried calling the calculatedXY() directly in resizeEvent(), the line is drawn but not scaled when window is maximized. It is scaled only when I call the whole drawPath().
However, even calling directly calculatedXY() in resizeEvent(), the lag persists. Still appx 4 secs delay....
I have tried changing the size of the background img, even removed it, but still get the same result. I have no idea what could be a reason....