Unsolved sometimes qt was ended forcefully, weird.
-
As @J-Hilk already told you 4 days ago - don't create an eventloop in a resize event!
-
@Christian-Ehrlicher
thanks, i am not 100% sure about that answer, but i will try another solution. now the question is, where do i get the size of centralwidget automatically when QMainWindows is in fullscreen (showFullScreen() in c'tor)? i tried showEvent and C'tor but failed to get the right size. -
@circle
I admit I have not tried it but I would have expected it inshowEvent()
as we discussed earlier. Could you show where you put what code for that? -
I still don't understand the need to know the size of a widget at all - your code you showed us doesn't do anything with it. Use layouts...
-
@JonB
qDebug to print the line and ui->centralwidget->width() -
@Christian-Ehrlicher
well, i am supposed to do some complicated drawings as the background based on the size of centralwidget, there maybe several different solutions and i never use layouts before. those code was migrated from windows. -
@circle said in sometimes qt was ended forcefully, weird.:
qDebug to print the line and ui->centralwidget->width()
Can you show just the few lines of code where you do this? What method it's in and where you do it.
-
@circle said in sometimes qt was ended forcefully, weird.:
i am supposed to do some complicated drawings as the background
You can't draw on a widget outside the paintEvent()...
-
@JonB said in sometimes qt was ended forcefully, weird.:
@circle said in sometimes qt was ended forcefully, weird.:
qDebug to print the line and ui->centralwidget->width()
Can you show just the few lines of code where you do this? What method it's in and where you do it.
void MainWindow::showEvent(QShowEvent * event) { QMainWindow::showEvent(event); qDebug() << "w: " << ui->centralwidget->width() << "h: " << ui->centralwidget->height(); }
-
@Christian-Ehrlicher said in sometimes qt was ended forcefully, weird.:
@circle said in sometimes qt was ended forcefully, weird.:
i am supposed to do some complicated drawings as the background
You can't draw on a widget outside the paintEvent()...
maybe paintEvent() is a better way, but i'm using eventFilter() instead (i am new to qt), more specifically, most of drawings are in the memory, such as qpixmap, qpainterpath, and they are working fine.
-
But not in your example you show above - there you do a lot of stuff which doesn't belong to a resize (or paint)Event. I gave you a lot of examples on how to change it. Giving up.