Results 1 to 15 of 15

Thread: draw a point

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: draw a point

    Starting /home/MALEK/soso-build-desktop/soso...
    QPainter::begin: Paint device returned engine == 0, type: 2
    QPainter::setRenderHint: Painter must be active to set rendering hints
    QPainter::save: Painter not active
    QPainter::setClipRect: Painter not active
    QPainter::setWorldTransform: Painter not active
    QPainter::worldTransform: Painter not active
    QPainter::save: Painter not active
    QPainter::setWorldTransform: Painter not active
    QPainter::setOpacity: Painter not active
    QPainter::setPen: Painter not active
    QPainter::setBrush: Painter not active
    QPainter::drawRects: Painter not active
    QPainter::restore: Unbalanced save/restore
    QPainter::setWorldTransform: Painter not active
    QPainter::restore: Unbalanced save/restore
    QPainter::end: Painter not active, aborted
    /home/MALEK/soso-build-desktop/soso exited with code 0
    Even When I use the code of the tutorial this msgs appears !!

    I use this code
    Qt Code:
    1. scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green));
    2.  
    3. QPixmap pixmap;
    4. QPainter painter(&pixmap);
    5. painter.setRenderHint(QPainter::Antialiasing);
    6. scene.render(&painter);
    7. painter.end();
    8.  
    9. pixmap.save("scene.png");
    To copy to clipboard, switch view to plain text mode 

    from this link:
    http://doc.qt.nokia.com/4.6/graphicsview.html

  2. #2
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: draw a point

    It is very simple issue.I just draw it like this

    Qt Code:
    1. QPen pen;
    2. pen.color().blue();
    3. scene->addEllipse(QRectF(0,0 ,10 ,10 ), pen, QBrush(Qt::red));
    4. ui->graphicsView->setScene(scene);
    To copy to clipboard, switch view to plain text mode 

    NOW !!!
    You MUST help me in this.

    1) I want to change the point location. It is always in the same location even when I replace (0,0 ,10,10) by (168,324,10,10) for example.

    2) How can I change the location of the point as (Lat, Lon),Since my background will be the map of the WORLD.


    THANKS FOR ALL.

  3. #3
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: draw a point

    911 !!
    Help me please !!

  4. #4
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: draw a point

    Quote Originally Posted by Malek View Post
    1) I want to change the point location. It is always in the same location even when I replace (0,0 ,10,10) by (168,324,10,10) for example.
    From the docs: "Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0)." If you only have one item on your scene it will always be in the same location. Try adding two ellipse items.

    2) How can I change the location of the point as (Lat, Lon),Since my background will be the map of the WORLD.
    Try something like this:
    Qt Code:
    1. QPixmap pixmap("/path/to/worldmap.jpg");
    2. scene.addPixmap(pixmap);
    3. scene.addEllipse(QRectF(168,324,10,10),QPen(Qt::red),QBrush(Qt::red));
    4. QGraphicsView view(&scene);
    5. view.show();
    To copy to clipboard, switch view to plain text mode 
    You'll have to handle translating lat/long to scene coordinates.

Similar Threads

  1. Replies: 1
    Last Post: 3rd December 2009, 14:23
  2. Replies: 6
    Last Post: 21st September 2009, 10:55
  3. display a plot point by point
    By oswalidos in forum Newbie
    Replies: 32
    Last Post: 13th March 2009, 15:37
  4. draw point with mouseevent
    By konvex in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2008, 04:49
  5. how to paint scene point by point
    By elessaar in forum Qt Programming
    Replies: 8
    Last Post: 4th September 2008, 20:00

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.