Results 1 to 4 of 4

Thread: Painting directly on the scene

  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 Painting directly on the scene

    Hi guys,

    I have a question. I the drawBackground(QPainter* painter) I am drawing my scene background, simple as that. The user, though, should be able to draw some other lines, polygons dynamically(with some give coordinates). I can do that adding items(as addline,addpolygon, etc, add items), but I would like to draw simply on the scene, using scene coordinates, using scene painter. Is it possible?

    Maverick
    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,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Painting directly on the scene

    You can't draw "on the scene". Scene is not drawable in any way. The only way to change the scene (which in turn will be visualized by the views) is to add items. So you can either add items to the scene or draw on the view's viewport (which is really not advised).

  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

    Default Re: Painting directly on the scene

    Ok, that's understandable. So would it be a better idea to use a simple widget and paint on it? I am currently using QGraphicsView Framework, but I am wondering was it the best solution. I am drawing a map and have to draw some more items when user choses to do so(about thousands of items), have to zoom in/out, find object, collision, etc.

    let's say, I have to add 100 000(or even a 1000 000) polygon items to the scene. How hard would it be to optimize it so I would see any painting lag/clutter while zoomin/out?

    But is the GraphicsView Framework the best solution for this?..

    Thank you for help.
    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,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Painting directly on the scene

    Assuming you're implementing something similar to googlemaps and you want to place pins, labels or whatever, I'd go for graphics view and implement all those pins and other stuff as graphics items. Graphics View should work fine even for millions of items. Of course you can reduce the number of items by dynamically adding or removing them from the scene just like google does.

Similar Threads

  1. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51
  2. How to use QGraphicsView and Scene right ...
    By Mike in forum Qt Programming
    Replies: 6
    Last Post: 22nd January 2007, 08:51

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.