I understood why the image wasn't displayed. I should wrote QFrame instead of QGraphicsView.
view->setStyleSheet("QFrame { background-image: url(grid.png) ;"
"background-repeat: repeat }");
view->setStyleSheet("QFrame { background-image: url(grid.png) ;"
"background-repeat: repeat }");
To copy to clipboard, switch view to plain text mode
But I don't understand what is doing background-repeat option.
Is it repeat background image without scaling??? (I don't think so)
Here I want to show how I do zoom operation.
void LayoutEditor::zoomIn()
{
scaleFactor *= 1.25;
view->scale(1.25, 1.25);
if(scaleFactor >= 1.0) {
// which function to use??????
//view->setBackgroundBrush(QBrush(QPixmap("Resources\\grid.png")));
//view->setStyleSheet("QFrame { background-image: url(grid.png) ;"
"background-repeat: repeat }");
}
...
}
void LayoutEditor::zoomOut()
{
scaleFactor *= 0.8;
view->scale(0.8, 0.8);
if(scaleFactor < 1.0) {
view
->setBackgroundBrush
(QBrush(Qt
::black));
}
...
}
void LayoutEditor::zoomIn()
{
scaleFactor *= 1.25;
view->scale(1.25, 1.25);
if(scaleFactor >= 1.0) {
// which function to use??????
//view->setBackgroundBrush(QBrush(QPixmap("Resources\\grid.png")));
//view->setStyleSheet("QFrame { background-image: url(grid.png) ;"
"background-repeat: repeat }");
}
...
}
void LayoutEditor::zoomOut()
{
scaleFactor *= 0.8;
view->scale(0.8, 0.8);
if(scaleFactor < 1.0) {
view->setBackgroundBrush(QBrush(Qt::black));
}
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks