Results 1 to 4 of 4

Thread: Problem with fill style

  1. #1
    Join Date
    Jul 2009
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with fill style

    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.

    Qt Code:
    1. view->setBackgroundBrush(QPixmap("Resources\\grid.png"));
    To copy to clipboard, switch view to plain text mode 

    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.
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2008
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with fill style

    one quick fix could be to set the background image in a style sheet with background-repeat option

  3. #3
    Join Date
    Jul 2009
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with fill style

    Thank you for replying.

    I never use style sheets.

    Do you mean this?

    Qt Code:
    1. view->setStyleSheet("QGraphicsView {background-image: url(Resources\\grid.png); "
    2. "background-repeat: repeat; }");
    To copy to clipboard, switch view to plain text mode 

    What I've written wrong?

  4. #4
    Join Date
    Jul 2009
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with fill style

    I understood why the image wasn't displayed. I should wrote QFrame instead of QGraphicsView.

    Qt Code:
    1. view->setStyleSheet("QFrame { background-image: url(grid.png) ;"
    2. "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.

    Qt Code:
    1. void LayoutEditor::zoomIn()
    2. {
    3. scaleFactor *= 1.25;
    4. view->scale(1.25, 1.25);
    5. if(scaleFactor >= 1.0) {
    6. // which function to use??????
    7. //view->setBackgroundBrush(QBrush(QPixmap("Resources\\grid.png")));
    8. //view->setStyleSheet("QFrame { background-image: url(grid.png) ;"
    9. "background-repeat: repeat }");
    10. }
    11. ...
    12.  
    13. }
    14.  
    15. void LayoutEditor::zoomOut()
    16. {
    17. scaleFactor *= 0.8;
    18. view->scale(0.8, 0.8);
    19. if(scaleFactor < 1.0) {
    20. view->setBackgroundBrush(QBrush(Qt::black));
    21. }
    22. ...
    23.  
    24. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Mac Style for Qt Application---help needed
    By swamyonline in forum Qt Programming
    Replies: 3
    Last Post: 15th June 2008, 21:49
  2. Loading / setting custom style on win-xp
    By mpotocnik in forum Newbie
    Replies: 0
    Last Post: 29th April 2008, 11:38
  3. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  4. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.