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. Need a control to show a image and draw on it and scrollable

Need a control to show a image and draw on it and scrollable

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 760 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.
  • jronaldJ Offline
    jronaldJ Offline
    jronald
    wrote on last edited by jronald
    #1

    02af239a-8be9-4e6f-8f12-0c6164800a74-image.png

    For example, as shown above, load a image and draw on it.
    When the image is larger than the control, scrollbars are support.
    Which control is most suitable?

    Pl45m4P 1 Reply Last reply
    0
    • jronaldJ jronald

      02af239a-8be9-4e6f-8f12-0c6164800a74-image.png

      For example, as shown above, load a image and draw on it.
      When the image is larger than the control, scrollbars are support.
      Which control is most suitable?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @jronald

      QScrollArea + QLabel with QPixmap for the image

      • https://doc.qt.io/qt-5/qscrollarea.html
      • https://doc.qt.io/qt-5/qlabel.html

      Or have a look at the Graphics View Framework:

      • https://doc.qt.io/qt-5/graphicsview.html

      There are also some MS Paint-like examples using Graphics View or a plain widget as canvas to draw on:

      • https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

      (Mabye you can use this example as template since it almost does what you want to do)


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      jronaldJ 1 Reply Last reply
      2
      • Pl45m4P Pl45m4

        @jronald

        QScrollArea + QLabel with QPixmap for the image

        • https://doc.qt.io/qt-5/qscrollarea.html
        • https://doc.qt.io/qt-5/qlabel.html

        Or have a look at the Graphics View Framework:

        • https://doc.qt.io/qt-5/graphicsview.html

        There are also some MS Paint-like examples using Graphics View or a plain widget as canvas to draw on:

        • https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

        (Mabye you can use this example as template since it almost does what you want to do)

        jronaldJ Offline
        jronaldJ Offline
        jronald
        wrote on last edited by jronald
        #3

        @Pl45m4
        I prefer a single control like QWidget, how to make it scrollable?
        I've checked the Scribble Example, it doesn't support scrollbar.

        Pl45m4P 1 Reply Last reply
        0
        • jronaldJ jronald

          @Pl45m4
          I prefer a single control like QWidget, how to make it scrollable?
          I've checked the Scribble Example, it doesn't support scrollbar.

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @jronald

          There is no such single widget...
          Qt is a programming framework, not plug and play :)
          Something (or most of the times) you have to make your own widgets and implement your own behavior to get what you want.

          I said you could use the scribble example as template, not "take it and you are done". Of course it might need some additional coding to get from it, what you expect.

          If you have a canvas widget, where you can draw on, you can put it in a QScrollArea and voilà, it's scrollable...

          Btw: You can make a custom and single QWidget from any other combination of QWidgets, so it can be used and "cloned" multiple times on your GUI.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          jronaldJ 1 Reply Last reply
          1
          • Pl45m4P Pl45m4

            @jronald

            There is no such single widget...
            Qt is a programming framework, not plug and play :)
            Something (or most of the times) you have to make your own widgets and implement your own behavior to get what you want.

            I said you could use the scribble example as template, not "take it and you are done". Of course it might need some additional coding to get from it, what you expect.

            If you have a canvas widget, where you can draw on, you can put it in a QScrollArea and voilà, it's scrollable...

            Btw: You can make a custom and single QWidget from any other combination of QWidgets, so it can be used and "cloned" multiple times on your GUI.

            jronaldJ Offline
            jronaldJ Offline
            jronald
            wrote on last edited by
            #5

            @Pl45m4 said in Need a control to show a image and draw on it and scrollable:

            If you have a canvas widget, where you can draw on, you can put it in a QScrollArea

            Tried: https://forum.qt.io/topic/133473/no-scrollbars-when-put-qwidget-derived-class-object-in-qscrollarea
            But scrollbars don't appear, what the problem?

            Pl45m4P 1 Reply Last reply
            0
            • jronaldJ jronald

              @Pl45m4 said in Need a control to show a image and draw on it and scrollable:

              If you have a canvas widget, where you can draw on, you can put it in a QScrollArea

              Tried: https://forum.qt.io/topic/133473/no-scrollbars-when-put-qwidget-derived-class-object-in-qscrollarea
              But scrollbars don't appear, what the problem?

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by Pl45m4
              #6

              @jronald

              Is the widget larger than the scrollable area? If not, there's no need for scrollBars. Only if the widget's height/width exceeds the area, the scrollBars appear.
              So you probably need to make your widget bigger


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              1

              • Login

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