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. Qt Draw/drag and drop
Forum Updated to NodeBB v4.3 + New Features

Qt Draw/drag and drop

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.8k Views 1 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.
  • D Offline
    D Offline
    deranjer
    wrote on last edited by
    #1

    I have a question about Qt development gui options. I want to create a garden bed layout program, so I want to create a "draw" interface, where the user can "draw" on a grid to lay out the garden beds (and right click on the squares to "plant seeds"). Is this possible in Qt?

    This link is http://i59.tinypic.com/eg2wkh.png the start of my gui prototype for the main window. I drew the graph manually right now, and if I need to I can do that again.

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

      Hi,

      You have several way to do it, e.g. QML, QGraphicsView. You should have a look at the demos & examples from the documentation to see which solution provides what's you want.

      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
      • D Offline
        D Offline
        deranjer
        wrote on last edited by
        #3

        I'm using Pyside to create the application (I'm very new to python and QT), and have the following code to create the background "grid":

        @class mainWindow(QtGui.QMainWindow, Ui_mainWindow):
        def init(self, parent=None):
        QtGui.QMainWindow.init(self, parent)
        self.setupUi(self) #draw all the UI elements
        #drawing the SFG grid
        scene = QtGui.QGraphicsScene()
        for x in range (-500, 500, 60):
        for y in range (-300, 300, 60):
        scene.addRect(QtCore.QRectF(x,y,60,60))

            self.gridView.setScene(scene)@
        

        Now I would like to draw a bold line around a set number of boxes (defining bed sizes) and then be able to click on individual boxes and add pictures to each box (showing plants).

        This works, but I can't create a mouse event in the same class apparently, but I can't seem to create a scene class that works:
        @class createScene(QtGui.QGraphicsScene):
        def init(self, parent=None):
        QtGui.QGraphicsScene.init(self, parent)
        gridScene = QtGui.QGraphicsScene()
        for x in range (-500, 500, 60):
        for y in range (-300, 300, 60):
        gridScene.addRect(QtCore.QRectF(x,y,60,60)) @

        How can I capture mouse events in the scene, and how do I select the boxes I created?

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

          Then, you should really have a look at the QGraphicsScene related examples and classes, they will provide you with the building blocks you need

          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
          • D Offline
            D Offline
            deranjer
            wrote on last edited by
            #5

            Unfortunately, the direct Qt documentation doesn't help me much, as I don't know any C++. I've read the PySide documentation on it, but that doesn't provide any examples on how to code it, so I don't really have any way to figure out how to program it.

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

              Have a look "here":https://qt.gitorious.org/pyside/pyside-examples/source/060dca8e4b82f301dfb33a7182767eaf8ad3d024:examples there's the example you've been searching :)

              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