Results 1 to 3 of 3

Thread: QBrush pattern problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QBrush pattern problem

    Indeed, it behaves strange. Especially when you resize the widget. It might be a result of some round-off errors, but IMO you should show this example to the Trolls.

    Below is a working example:
    Qt Code:
    1. #include <QApplication>
    2. #include <QPainter>
    3. #include <QWidget>
    4.  
    5. class Test : public QWidget
    6. {
    7. protected:
    8. void paintEvent( QPaintEvent * )
    9. {
    10. QPainter painter(this);
    11. painter.setPen(Qt::red);
    12.  
    13. QBrush brush(Qt:: Dense6Pattern);
    14. brush.setColor(Qt::blue);
    15. painter.setBrush(brush);
    16.  
    17. painter.setWindow(0, 0, 1000, 1000); // try to comment out this line
    18. painter.drawRect(50, 50, 100, 200);
    19.  
    20. painter.setWindow(0, 0, 2000, 2000);
    21. painter.drawRect(500, 100, 200, 400);
    22.  
    23. painter.setWindow(0, 0, 3000, 3000);
    24. painter.drawRect(1350, 150, 300, 600);
    25.  
    26. painter.setWindow(0, 0, 4000, 4000);
    27. painter.drawRect(2600, 200, 400, 800);
    28.  
    29. painter.setWindow(0, 0, 5000, 5000);
    30. painter.drawRect(4250, 250, 500, 1000);
    31. }
    32. };
    33.  
    34. int main( int argc, char **argv )
    35. {
    36. QApplication app( argc, argv );
    37.  
    38. Test t;
    39. t.show();
    40.  
    41. return app.exec();
    42. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to jacek for this useful post:

    ilovethisgame (10th July 2006)

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  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.