yeah!
(...) <-other widgets, not important
mainView->setAutoFillBackground(true);
mainView->setScene(scene);
(...)
void MainWindow::setOp_S(int o)
{
qreal opac=o/100.0;
scene->items()[1]->setOpacity(opac);
scene->update(scene->sceneRect());
mainView->update();
update();
}
scene=new QGraphicsScene;
mainView= new QGraphicsView;
(...) <-other widgets, not important
mainView->setAutoFillBackground(true);
mainView->setScene(scene);
(...)
void MainWindow::setOp_S(int o)
{
qreal opac=o/100.0;
scene->items()[1]->setOpacity(opac);
scene->update(scene->sceneRect());
mainView->update();
update();
}
To copy to clipboard, switch view to plain text mode
and here is how i change the size of image in main view:
void MainWindow::scaleImage_S(double ratio)
{
mainView->scale(scaleBack,scaleBack);
double scaleRatio=ratio/(double)100;
scaleBack=1/(double)scaleRatio;
mainView->scale(scaleRatio,scaleRatio);
actionZoomIn->setEnabled(pWidget->getRatio()<800);
actionZoomOut->setEnabled(pWidget->getRatio()>4);
}
void MainWindow::scaleImage_S(double ratio)
{
mainView->scale(scaleBack,scaleBack);
double scaleRatio=ratio/(double)100;
scaleBack=1/(double)scaleRatio;
mainView->scale(scaleRatio,scaleRatio);
actionZoomIn->setEnabled(pWidget->getRatio()<800);
actionZoomOut->setEnabled(pWidget->getRatio()>4);
}
To copy to clipboard, switch view to plain text mode
the problem is only when the view in main view is 100% of image, not in upscale or downscale, i'm not using any of my functions to rescale image, just build-in QGraphicsView::Scale
after rendering the scene, no matter of size and scale, the result picture is ruined... i'm stuck...
Fixed the problem. If someone is interested in the solution, just ask by posting here.
Bookmarks