Jump to content

ignore, solved by self

CookieMaster
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. 

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

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

Link to comment
Share on other sites

Link to post
Share on other sites

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
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
Share on other sites

Link to post
Share on other sites

22 hours ago, Pinguinsan said:

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?).

Yes it works fine!!

Link to comment
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

×