Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Display multiple Images on a nother image (e.g map with markers)
QtWS25 Last Chance

Display multiple Images on a nother image (e.g map with markers)

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 4 Posters 3.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    somenickname
    wrote on last edited by
    #1

    Hello,

    I'm way of new to QT and currently looking for the required classes to create a simple window with an image as background, on which I can display multiple other small images.

    Most important is that I can choose coordinates for the small images. That is to say: When I have a 1280x400 window, I would like to be able an image at exactly x=640,y=400 for the middle of the window.

    Advice would be very appreciated ;)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You might be interested by the "QGraphicsScene":http://qt-project.org/doc/qt-4.8/qgraphicsscene.html, "QGraphicsView":http://qt-project.org/doc/qt-4.8/qgraphicsview.html and their friends for that

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        Hi,

        Just in case if your want to do using QML:

        1. You can use "Rectangle":http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-rectangle.html and specify size to it.
        2. Then inside it you can use "Image":http://qt-project.org/doc/qt-4.8/qdeclarativeelements.html to add an image to the Rectangle.
          Set Image.fillMode as per your requirement (eg. fillMode: Image.PreserveAspectFit).
        3. After that you can added Image items as per your need and set parent to the "Rectangle" item your have added. You can then set "x" and "y" coordinates for the item.
        4. If you want to center the item just set the positions of the Image Items added in pt. 3 using "anchors.centerIn: parent"

        157

        1 Reply Last reply
        0
        • S Offline
          S Offline
          somenickname
          wrote on last edited by
          #4

          [quote author="SGaist" date="1379587266"]Hi and welcome to devnet,

          You might be interested by the "QGraphicsScene":http://qt-project.org/doc/qt-4.8/qgraphicsscene.html, "QGraphicsView":http://qt-project.org/doc/qt-4.8/qgraphicsview.html and their friends for that

          Hope it helps[/quote]

          Perfectly does the trick.

          Just one thing: Is it possible to enforce that changes (like hiding a child object, or moving it to an other position) are repainted all at once?

          Like:
          window.freeze();
          img1.move();
          img2.move();
          window.rerender();

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You might try with setUpdatesEnabled

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              somenickname
              wrote on last edited by
              #6

              Ah, hey. Thanks a lot.

              Guess there is only one last problem:

              map.h
              [CODE]
              #include <QtWidgets/QGraphicsScene>
              #include <QtWidgets/QGraphicsView>
              #include <vector>

              class Map
              {
              public:
              Map();

              private:
                  QGraphicsScene map;
                  QGraphicsView view;
              

              };
              [/CODE]

              map.cpp
              [CODE]
              #include "map.h"

              #include <QtWidgets/QGraphicsScene>
              #include <QtWidgets/QGraphicsView>

              Map::Map()
              {
              this->map = QGraphicsScene(QPixmap("map.jpg"));
              this->view = QGraphicsView(&this->map);
              }
              [/CODE]

              Getting the following error:
              C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtCore\qglobal.h:946: Fehler:'QGraphicsView& QGraphicsView::operator=(const QGraphicsView&)' is private
              Class &operator=(const Class &) Q_DECL_EQ_DELETE;
              ^

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You can't copy QObject (the details are in the documentation)

                Change map and view to pointers

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  QT PROFESSIONAL
                  wrote on last edited by
                  #8

                  попробуй в кьют виджет с помощью штмл решить

                  Windows 8 qt for Nokia N 8-00

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    somenickname
                    wrote on last edited by
                    #9

                    Works for me with init lists, my C++ used to be better in former days.

                    Getting some linker errors like:
                    map.cpp:-1: Fehler:undefined reference to `_imp___ZN7QWidget6resizeERK5QSize'

                    How to properly set up the make file? Seems like QT Creator is not able to.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Since you're using Qt 5, are you missing:

                      @QT += widgets@

                      in your pro file ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        somenickname
                        wrote on last edited by
                        #11

                        nvm, got it running.

                        Just seems like Qt wont allow me to continously update the map in the main thread (cause Qapp.exec() never gets called that way), and passing the map to another thread doesnt work either: "QObject::startTimer: timers cannot be started from another thread"

                        I guess I gotta make use of callbacks.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          How frequently are you updating your data ? Does it take time ? If not, you could simply use a QTimer (or the timerEvent of the widget handling the map).

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved