PDA

View Full Version : Problem with fill style



hasmik
13th July 2009, 18:32
Hello!!!

Please, look at attached pictures.
I want dispaly items on a grid texture. So mouse could move across discrete points. To obtain grid appearance I set view's background brush with pixmap.



view->setBackgroundBrush(QPixmap("Resources\\grid.png"));


But I met some problems. When I do zoom action the discrete points are zooming too. Item's fill texture spoilt too. But I want to zoom only GarphicsItems' sizes but not fillstyle and grid texture.

Please, give me advice to solve this problem.

manishkyl
13th July 2009, 19:24
one quick fix could be to set the background image in a style sheet with background-repeat option

hasmik
14th July 2009, 12:54
Thank you for replying.

I never use style sheets.

Do you mean this?



view->setStyleSheet("QGraphicsView {background-image: url(Resources\\grid.png); "
"background-repeat: repeat; }");


What I've written wrong?

hasmik
14th July 2009, 17:07
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 }");


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));
}
...

}