Results 1 to 6 of 6

Thread: Painter brush question

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Painter brush question

    Hi guys,

    When no scaling is done I can draw using Qt:enseXPattern without any problem;
    There is a need for scaling my graphcisscene about 90times ( scene rect is 90times smaller) and I have to fill a rect(in the drawBackground method) with the Qt::denseXPattern and no brush is shown;
    I can only use Solid brushes with the same result despite the current scene scale;
    Maybe this is a trivial questions, but can't find the answer.
    If anyone has the answer I would really appreciate a short piece of code or an example app showing that the brush may look the same despite the scene rect size;

    Any ideas?
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Painter brush question

    If the scene is smaller then you see everything magnified, correct? And then the brush is transparent? Could you post a screenshot of what you get and what you would expect to see?

  3. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy Re: Painter brush question

    Hi,

    This is a pretty simple code, used for checking drawing:
    Assume I have a list of polygons: PolygonList;
    Assume the polygons are inside 0.5 of a degree, and the whole scene is a rect (-180,-90, 360,180), so polygons are invisible when the whole scene is drawn, but I have to zoom in about 200 times, etc.
    Qt Code:
    1. // First I have some code to set brush color
    2. QBrush br = _painter->brush();
    3. br.setStyle(Qt::Dense4Pattern);
    4. _painter->setBrush(br);
    5. for(int i=0;i<PolygonList.size();++i)
    6. {
    7. _painter->drawPolygon(PolygonList.at(i));
    8. }
    To copy to clipboard, switch view to plain text mode 
    What this code does is:
    When I fit my chart(set of polygons) into scene, so all polygons are visible the brush is ok, and my polygons are filled with the given brush, but when I zoom in the polygons are not filled with any color, are transparent. Then, when I zoom out, and zoom out, and zoom out, the polygons are filled with color. Still, when I fit my chart in the scene and try to zoom in the polygons are not filled with any color.

    THIS IS BASICALLY WHAT I need to to achieve: the same brush no matter the scale of the chart(zooming in /out )
    Should the brush be scaled as well as the scene? I have started Brush in depth study, so this question may be trivial.

    Any ideas.

    Thanks
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Painter brush question

    I don't think there is a way to make the pattern transformation invariant. You can make the whole item transformation invariant and manipulate its geometry when zooming or implement your own pattern that will consider the level of detail.

  5. #5
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Painter brush question

    Hi,

    Yes, you're right. The brush is used for drawing some parts of the the scene's background. I can't change to an item. I tried scaling the the brush along zooming in, but is has the same effect as without scaling the brush. It's a bit strange, but I am sure it can be done. How? yet do not know : )

    THank you

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  6. #6
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Painter brush question

    In Munich I was given an advice to use a QImage as a pattern and scale it along zooming in/out.
    I am currently working on it and will reply when it's working; and paste the code.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

Similar Threads

  1. Scaling
    By AD in forum Qt Programming
    Replies: 16
    Last Post: 11th July 2008, 10:55
  2. How to manage QPainter?
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 13:20

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.