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. Designer for restaurant floor plan maker
Forum Updated to NodeBB v4.3 + New Features

Designer for restaurant floor plan maker

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 521 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
    Max13
    wrote on last edited by
    #1

    I'm writing a floor plan maker for a restaurant, I'm looking for advice on whether I'm going in the right direction or if there are better/more practical ways.

    Currently, I'm heavily relying on mousePressEvent() to store the current position of the mouse, mouseReleaseEvent() to detect if it was a drag or a click, and I'm painting the QRect in paintEvent().

    So, in the end, I'm only painting dots (for the grid) and rectangles inside a QWidget, if I want to allow the user to drag a table, then I must detect if I'm on a rectangle or not in mousePressEvent(). It seems straightforward to me but I wonder if I could have implemented that differently than using paintEvent()?

    We all have started by asking questions. Then after some time, we can begin answering them.

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

      Hi
      For such App, I would go with
      https://doc.qt.io/qt-5/graphicsview.html

      as then you get selection / dragging / zooming / panning / groups all for free. (or VERY little code)

      You can even use QPainter to paint the custom items and still have all the rest.

      Try out this example and see
      https://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html

      M 1 Reply Last reply
      4
      • mrjjM mrjj

        Hi
        For such App, I would go with
        https://doc.qt.io/qt-5/graphicsview.html

        as then you get selection / dragging / zooming / panning / groups all for free. (or VERY little code)

        You can even use QPainter to paint the custom items and still have all the rest.

        Try out this example and see
        https://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html

        M Offline
        M Offline
        Max13
        wrote on last edited by
        #3

        @mrjj Very nice suggestion thank you! I'm experimenting since yesterday and it's nice.

        I'm currently "drawing" custom QGraphicsItem as invisible squares with a dot on the center, and the dot is supposed to be a snapping grid, corners of a table can only be drawn on a dot. The inside of the item is supposed to detect where the mouse is. So these items are only used to detect hovering.

        Then, on drag from a "dot", I'm supposed to draw a QGraphicsRectItem, itself movable, resizable, etc… Is it the right way to use the Graphics View Framework?

        I'm still open to eventual other suggestions.

        We all have started by asking questions. Then after some time, we can begin answering them.

        mrjjM 1 Reply Last reply
        0
        • M Max13

          @mrjj Very nice suggestion thank you! I'm experimenting since yesterday and it's nice.

          I'm currently "drawing" custom QGraphicsItem as invisible squares with a dot on the center, and the dot is supposed to be a snapping grid, corners of a table can only be drawn on a dot. The inside of the item is supposed to detect where the mouse is. So these items are only used to detect hovering.

          Then, on drag from a "dot", I'm supposed to draw a QGraphicsRectItem, itself movable, resizable, etc… Is it the right way to use the Graphics View Framework?

          I'm still open to eventual other suggestions.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Max13
          Good to hear. Yes for a floor plan app it should give a lot of nice features.

          Hmm. Im not 100% sure what you mean with that dot.

          I assume you want something like
          https://www.walletfox.com/course/qgraphicsitemsnaptogrid.php

          where it uses drawBackground to draw a grid and then the Items itemChange that can catch the movement and adjust the placement to hit the grid.

          M 1 Reply Last reply
          0
          • mrjjM mrjj

            @Max13
            Good to hear. Yes for a floor plan app it should give a lot of nice features.

            Hmm. Im not 100% sure what you mean with that dot.

            I assume you want something like
            https://www.walletfox.com/course/qgraphicsitemsnaptogrid.php

            where it uses drawBackground to draw a grid and then the Items itemChange that can catch the movement and adjust the placement to hit the grid.

            M Offline
            M Offline
            Max13
            wrote on last edited by
            #5

            @mrjj Here is what I have done with paintEvent(), mouseMoveEvent(), mousePressEvent() and mouseReleaseEvent(), that's what I mean by "dot": https://imgur.com/a/cF5EeTW

            Now, using QGraphicsItem, I have subclassed it to Dot which has a square as Dot::boudingRect() and is painted as a 2px ellipse (a dot).

            Should I use my "dot" as a grid, and detect hover, press, and drags when the user is drawing a table, then constrain the user to this "grid" of Dot then add QGraphicsRectItem as the tables, OR maybe stick to paintEvent() to draw (exactly as I did on the video) and only use the Graphic View Framework for the tables ?

            We all have started by asking questions. Then after some time, we can begin answering them.

            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