I dont know the apropriate Class of QT.



  • hi all of you!

    I want to write a simple program with the Europe map as background and then i need the ability to plot the location on the map with the coordinates.
    My question is that i don't know which Class is the right class for this program. Can you help me ?



  • Hi,

    Is "this":http://doc.qt.io/qt-5/qtlocation-index.html what you are looking for?



  • i am not sure, i need some thing like this,

    http://gpredict.oz9aec.net/screenshots.php

    but only for Europe. a simple program not navigation and etc.


  • Lifetime Qt Champion

    Hi,

    Something like google map's pin ?



  • [quote author="SGaist" date="1421096731"]Hi,

    Something like google map's pin ?[/quote]

    is it offline? i think it's working only online.

    how can i use a picture as a background with Qt.
    Then i can use some maths to calculate the position on the picture.
    if the image is an array [x][y] then i can convert the coordinates as a pixel position.


  • Lifetime Qt Champion

    You can do that with a QLabel however the picture of a map can be quite big.

    "Marble":https://marble.kde.org/index.php might be an alternative



  • i tried last night the Class QGraphicsView and QGraphicsScene.
    Is that right ? but i have a problem, why the picture is not at corner ?
    see please thee screen-shot to understand.
    !http://i60.tinypic.com/29nb11f.png!



  • How can we judge that if you're now showing your code?
    However, just putting up a map as an image won't help you much in your quest to put things at specific coordinates on that map. You will need to deal with the projection for that, and you don't have control over that if you use an image.



  • one possibility...
    Viewport Anchor set to AnchorViewCenter

    As Andre says you should show some code I think.



  • Sorry i forgot the code
    @
    QGraphicsScene scene;
    scene.setSceneRect(-300, -300, 600, 600);
    //! [1] //! [2]
    scene.setItemIndexMethod(QGraphicsScene::NoIndex);
    scene.addItem(point);
    //! [4]
    QGraphicsView view(&scene);
    view.setRenderHint(QPainter::Antialiasing);
    view.setBackgroundBrush(QImage(":/images/map.jpg"));
    //! [4] //! [5]
    view.setCacheMode(QGraphicsView::CacheBackground);
    view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    view.setDragMode(QGraphicsView::ScrollHandDrag);
    //! [5] //! [6]
    view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Europe map test"));
    view.resize(400, 300);
    view.show();
    @



  • if you change scene.setSceneRect(-300, -300, 600, 600);
    scene.setSceneRect(0, 0, 600, 600); your image should align with the top left corner if that is what you want.



  • [quote author="kenchan" date="1421154626"]if you change scene.setSceneRect(-300, -300, 600, 600);
    scene.setSceneRect(0, 0, 600, 600); your image should align with the top left corner if that is what you want.

    [/quote]
    i make this @
    QGraphicsScene scene;
    scene.setSceneRect(0,0, QImage(":/images/map.jpg").width(), QImage(":/images/map.jpg").height());@

    it looks very good
    Thnx


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.