Jump to content

ignore, solved by self

Go to solution Solved by CookieMaster,
11 hours ago, Pinguinsan said:

void MainWindow::on_close_clicked()
{
	ui->graphicsView->clear();
	ui->graphicsView->viewPort().update(); 
}

The viewPort update may or may not be necessary, see here

 error: 'class QGraphicsView' has no member named 'clear'
     ui->graphicsView->clear();
                       ^

 

: error: 'class QGraphicsView' has no member named 'viewPort'
     ui->graphicsView->viewPort().update();
                       ^

 

I found out that I can use 

scene->clear();
ui->graphicsView->items().clear();

but is what you had above better? 

 

Not sure what the difference between the 2 is to be honest. 

11 hours ago, Pinguinsan said:

void MainWindow::on_close_clicked()
{
	ui->graphicsView->clear();
	ui->graphicsView->viewPort().update(); 
}

The viewPort update may or may not be necessary, see here

 error: 'class QGraphicsView' has no member named 'clear'
     ui->graphicsView->clear();
                       ^

 

: error: 'class QGraphicsView' has no member named 'viewPort'
     ui->graphicsView->viewPort().update();
                       ^

 

I found out that I can use 

scene->clear();
ui->graphicsView->items().clear();

but is what you had above better? 

 

Not sure what the difference between the 2 is to be honest. 

Link to comment
https://linustechtips.com/topic/772601-ignore-solved-by-self/#findComment-9766407
Share on other sites

Link to post
Share on other sites

3 hours ago, CookieMaster said:

 error: 'class QGraphicsView' has no member named 'clear'
     ui->graphicsView->clear();
                       ^

 

: error: 'class QGraphicsView' has no member named 'viewPort'
     ui->graphicsView->viewPort().update();
                       ^

 

I found out that I can use 


scene->clear();
ui->graphicsView->items().clear();

but is what you had above better? 

 

Not sure what the difference between the 2 is to be honest. 

Ah, sorry about that, I was looking at the documentation for QGraphicsScene, not QGraphicsView. Yeah, it looks like your method works will work (does it?).

Link to comment
https://linustechtips.com/topic/772601-ignore-solved-by-self/#findComment-9767424
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×