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. Qpainter scale existing drawing not working
Forum Updated to NodeBB v4.3 + New Features

Qpainter scale existing drawing not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 683 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.
  • S Offline
    S Offline
    sujith D
    wrote on last edited by sujith D
    #1
    void CanvasWidget::drawData(float x,float y,float z)
    {
        QPainter painter(&canvasImage);
        painter.drawPoint(x, y);
    }
    

    Code for plotting point working fine

    void CanvasWidget::mouseReleaseEvent(QMouseEvent *event)
    {
            QPainter painter(&canvasImage);
            QTransform transform;
            transform.scale(5,5);
            painter.setTransform(transform);
            this->update();
    }
    

    Painter scale property not working
    I just want to zoom the draged portion.

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

      Hi,

      These are two different painters, why should the transform apply ?

      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
      1
      • O Offline
        O Offline
        ofmrew
        wrote on last edited by
        #3

        Also, I thought that all widget painting must be done in the paintEvent?

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

          That's correct. My question is why would the painter you create and modify in the mouseReleaseEvent method have any influence on the painting you do in the paintEvent ?

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

          S 1 Reply Last reply
          1
          • O Offline
            O Offline
            ofmrew
            wrote on last edited by
            #5

            I agree. The transform should be created and saved, then used in the paintEvent.

            1 Reply Last reply
            1
            • SGaistS SGaist

              That's correct. My question is why would the painter you create and modify in the mouseReleaseEvent method have any influence on the painting you do in the paintEvent ?

              S Offline
              S Offline
              sujith D
              wrote on last edited by
              #6

              @SGaist I want to zoom the dragged portion

              S 1 Reply Last reply
              0
              • S sujith D

                @SGaist I want to zoom the dragged portion

                S Offline
                S Offline
                sujith D
                wrote on last edited by
                #7

                @sujith-D
                Screenshot from 2020-01-02 16-05-31.png
                This is my painter screen, there is a blue rectangle(dragged portion). I just want to zoom that dragged portion.
                @SGaist I was using different painters for drawing this single picture. first painter is used for creating the background and second painter is used for creating the grid lines. Both are applaide on the same CanvasWidget.

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

                  But you are not using the other painter. You can draw on a QImage at any time but you are currently just creating a painter and do nothing with it.

                  Looks like you should setup everything and then do the painting.

                  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
                  1

                  • Login

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