Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connect CustomObjects with a line between them
Forum Updated to NodeBB v4.3 + New Features

Connect CustomObjects with a line between them

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.8k Views 2 Watching
  • 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.
  • M Offline
    M Offline
    MatheusIH
    wrote on 14 Mar 2018, 23:35 last edited by
    #1

    Hi, I'm very new to GUI programming. I'm scratching my ahead around this one:
    I want a button so that when its pressed gets the next two clicked objects and draw a line between them.
    What I don't know:

    1. Once the button is pressed getting the two clicked objects
    2. Drawing a Line and Connecting both objects so that if I move one the line will follow it (stretch, contract, break, etc)

    Basically, like an ER Diagram, since the objects here are all rectangles.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 15 Mar 2018, 07:29 last edited by
      #2

      Hi,

      Sounds like an "edit mode" button. Can you give a bit more details about what you are currently using ? Is it the graphics view framework ? Widgets ? QtQuick ?

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

      M 1 Reply Last reply 15 Mar 2018, 19:39
      0
      • S SGaist
        15 Mar 2018, 07:29

        Hi,

        Sounds like an "edit mode" button. Can you give a bit more details about what you are currently using ? Is it the graphics view framework ? Widgets ? QtQuick ?

        M Offline
        M Offline
        MatheusIH
        wrote on 15 Mar 2018, 19:39 last edited by
        #3

        @SGaist Sure, thanks for the reply! I'm creating a mainwindow using QGraphicsView to display movable objects which are custom QGraphicsItems. I want the user to be able to freely connect/disconnect these objects similar to the way an ER Diagram is made using MySQL workbench.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 15 Mar 2018, 20:15 last edited by
          #4

          You should take a look at the Elastic Nodes example.

          As for the click handling you might want to use an event filter that will act in "edit mode" to catch the two next click when the mode is activated.

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

          M 1 Reply Last reply 17 Mar 2018, 22:08
          3
          • S SGaist
            15 Mar 2018, 20:15

            You should take a look at the Elastic Nodes example.

            As for the click handling you might want to use an event filter that will act in "edit mode" to catch the two next click when the mode is activated.

            M Offline
            M Offline
            MatheusIH
            wrote on 17 Mar 2018, 22:08 last edited by
            #5

            @SGaist Thanks! That's precisely what I needed regarding the connected objects. As for the "edit mode" I'll have to read a bit more into it since I'm new to UI developing and Qt. Any links you can recommend me would be of great help.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 17 Mar 2018, 22:20 last edited by
              #6

              Nothing special about it. It's a bit like the "text/preview" you have with the markdown editor on e.g. Gitlab. In this case you have your application running "normally" and when you click on some button/menu item, you activate some additional layer that will handle the next two items you click.

              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
              • M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 17 Mar 2018, 22:29 last edited by
                #7

                Hi
                Just as a note
                This sample also allows connected objects
                http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html
                and can provide good basic if you make anything like a diagram editor.

                1 Reply Last reply
                1

                1/7

                14 Mar 2018, 23:35

                • Login

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