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. Draw basic Axes on QPixmap ?
QtWS25 Last Chance

Draw basic Axes on QPixmap ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qpixmapqchartqlabelaxisplot
29 Posts 6 Posters 7.7k Views
  • 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 mrjj
    14 Aug 2019, 15:28

    Hi
    Regarding the axis.
    One option is to simply draw them in inkscape and save as SVG.
    Then just paint the SVG on top of the image.
    That should be faster than draw the ticks and values by hand using painter.
    However, if axis values change or zoom is needed then its not good idea.

    R Offline
    R Offline
    R-P-H
    wrote on 14 Aug 2019, 16:26 last edited by
    #17

    @mrjj said in Draw basic Axes on QPixmap ?:

    Hi
    Regarding the axis.
    One option is to simply draw them in inkscape and save as SVG.
    Then just paint the SVG on top of the image.
    That should be faster than draw the ticks and values by hand using painter.
    However, if axis values change or zoom is needed then its not good idea.

    Hi, the "plot/image" is not interactive. The axis values do change but only each time a user changes a setting. So the axis would have to somehow be made on the fly for each "session". During the "session" the axis remain the same though while the image does change ! So I'm not sure what's the most efficient way of doing it...

    M 1 Reply Last reply 14 Aug 2019, 16:30
    0
    • R R-P-H
      14 Aug 2019, 16:26

      @mrjj said in Draw basic Axes on QPixmap ?:

      Hi
      Regarding the axis.
      One option is to simply draw them in inkscape and save as SVG.
      Then just paint the SVG on top of the image.
      That should be faster than draw the ticks and values by hand using painter.
      However, if axis values change or zoom is needed then its not good idea.

      Hi, the "plot/image" is not interactive. The axis values do change but only each time a user changes a setting. So the axis would have to somehow be made on the fly for each "session". During the "session" the axis remain the same though while the image does change ! So I'm not sure what's the most efficient way of doing it...

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 14 Aug 2019, 16:30 last edited by
      #18

      @r-p-h
      Well if its very dynamic then hand painting them with painter should do it.
      Overlaying a svg with only part of the axis is likely more fiddle fiddle to place the values correctly
      so just drawing it should be the way to go.
      Do you have image of the needed axis?

      R 1 Reply Last reply 14 Aug 2019, 18:42
      0
      • M mrjj
        14 Aug 2019, 16:30

        @r-p-h
        Well if its very dynamic then hand painting them with painter should do it.
        Overlaying a svg with only part of the axis is likely more fiddle fiddle to place the values correctly
        so just drawing it should be the way to go.
        Do you have image of the needed axis?

        R Offline
        R Offline
        R-P-H
        wrote on 14 Aug 2019, 18:42 last edited by
        #19

        @mrjj said in Draw basic Axes on QPixmap ?:

        @r-p-h
        Well if its very dynamic then hand painting them with painter should do it.
        Overlaying a svg with only part of the axis is likely more fiddle fiddle to place the values correctly
        so just drawing it should be the way to go.
        Do you have image of the needed axis?

        The image is live though so it's constantly being displayed in a loop, so I'm not sure if re-drawing the axes constantly is such a good idea.

        M 1 Reply Last reply 15 Aug 2019, 06:33
        0
        • R R-P-H
          14 Aug 2019, 18:42

          @mrjj said in Draw basic Axes on QPixmap ?:

          @r-p-h
          Well if its very dynamic then hand painting them with painter should do it.
          Overlaying a svg with only part of the axis is likely more fiddle fiddle to place the values correctly
          so just drawing it should be the way to go.
          Do you have image of the needed axis?

          The image is live though so it's constantly being displayed in a loop, so I'm not sure if re-drawing the axes constantly is such a good idea.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 15 Aug 2019, 06:33 last edited by
          #20

          @r-p-h
          oh, well for that sort of overlay,
          you will need to draw the axis
          anytime the image changes regardlessly.

          R 1 Reply Last reply 15 Aug 2019, 22:10
          0
          • M mrjj
            15 Aug 2019, 06:33

            @r-p-h
            oh, well for that sort of overlay,
            you will need to draw the axis
            anytime the image changes regardlessly.

            R Offline
            R Offline
            R-P-H
            wrote on 15 Aug 2019, 22:10 last edited by
            #21

            @mrjj said in Draw basic Axes on QPixmap ?:

            @r-p-h
            oh, well for that sort of overlay,
            you will need to draw the axis
            anytime the image changes regardlessly.

            Hi, Surely I could just draw (or plot ?) the axes once in the beginning and then just display or draw the image inside the plot. I think that re-drawing the axes every time will be very inefficient. Also manually drawing the tick marks and values seems like it could become tedious, so maybe using some form of QChart is the way to go...

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 16 Aug 2019, 06:24 last edited by
              #22

              Hi
              Well it sounds to me like the image is live ?
              Like a camera feed ?

              R 1 Reply Last reply 16 Aug 2019, 11:12
              0
              • M mrjj
                16 Aug 2019, 06:24

                Hi
                Well it sounds to me like the image is live ?
                Like a camera feed ?

                R Offline
                R Offline
                R-P-H
                wrote on 16 Aug 2019, 11:12 last edited by
                #23

                @mrjj said in Draw basic Axes on QPixmap ?:

                Hi
                Well it sounds to me like the image is live ?
                Like a camera feed ?

                Yes. Pretty much.

                1 Reply Last reply
                0
                • R R-P-H
                  12 Aug 2019, 12:41

                  Hi,

                  I have a QPixmap image that I put inside a label in Qt using ui->label->setPixmap(). I simply want to add some axes to the image with just basic tick marks, values and maybe axes labels. Everything I have seen so far is overly complicated using custom charts etc.

                  Is there any easy way I can draw some simple axes onto the image and display it in the label ? Or can I draw the axis onto the label and overlay the image ? Or can I overlay the image onto an axes image already set in the label ?

                  I'm really not sure how to go about this easily. Any suggestions ? Thanks.

                  A Offline
                  A Offline
                  anil_arise
                  wrote on 19 Aug 2019, 07:21 last edited by
                  #24

                  @r-p-h
                  QLabel *Label_backImg = new QLabel(this);
                  Label_backImg->setMinimumSize(80,80);
                  Label_backImg->setMaximumSize(80,80);
                  Label_backImg->setPixmap(QPixmap(":/images/edit-icon.png").scaled (Label_backImg->width(),Label_backImg->height(),Qt::KeepAspectRatio));

                  QLabel *labelIcon = new QLabel(Label_backImg);
                  labelIcon->setGeometry(40,8,40,40);
                  labelIcon->setPixmap(QPixmap(":/images/notification.png").scaled (labelIcon->width(),labelIcon->height(),Qt::KeepAspectRatio));
                  

                  result image is :
                  0_1566199247348_Screenshot_2019-08-19_12-49-21.png

                  R 1 Reply Last reply 19 Aug 2019, 09:28
                  0
                  • A anil_arise
                    19 Aug 2019, 07:21

                    @r-p-h
                    QLabel *Label_backImg = new QLabel(this);
                    Label_backImg->setMinimumSize(80,80);
                    Label_backImg->setMaximumSize(80,80);
                    Label_backImg->setPixmap(QPixmap(":/images/edit-icon.png").scaled (Label_backImg->width(),Label_backImg->height(),Qt::KeepAspectRatio));

                    QLabel *labelIcon = new QLabel(Label_backImg);
                    labelIcon->setGeometry(40,8,40,40);
                    labelIcon->setPixmap(QPixmap(":/images/notification.png").scaled (labelIcon->width(),labelIcon->height(),Qt::KeepAspectRatio));
                    

                    result image is :
                    0_1566199247348_Screenshot_2019-08-19_12-49-21.png

                    R Offline
                    R Offline
                    R-P-H
                    wrote on 19 Aug 2019, 09:28 last edited by
                    #25

                    @anil_arise said in Draw basic Axes on QPixmap ?:

                    @r-p-h
                    QLabel *Label_backImg = new QLabel(this);
                    Label_backImg->setMinimumSize(80,80);
                    Label_backImg->setMaximumSize(80,80);
                    Label_backImg->setPixmap(QPixmap(":/images/edit-icon.png").scaled (Label_backImg->width(),Label_backImg->height(),Qt::KeepAspectRatio));

                    QLabel *labelIcon = new QLabel(Label_backImg);
                    labelIcon->setGeometry(40,8,40,40);
                    labelIcon->setPixmap(QPixmap(":/images/notification.png").scaled (labelIcon->width(),labelIcon->height(),Qt::KeepAspectRatio));
                    

                    result image is :
                    0_1566199247348_Screenshot_2019-08-19_12-49-21.png

                    Hi, with this approach I will have to first create the axis externally and save them as some sort of a transparent image ?

                    A 1 Reply Last reply 19 Aug 2019, 09:54
                    0
                    • R R-P-H
                      19 Aug 2019, 09:28

                      @anil_arise said in Draw basic Axes on QPixmap ?:

                      @r-p-h
                      QLabel *Label_backImg = new QLabel(this);
                      Label_backImg->setMinimumSize(80,80);
                      Label_backImg->setMaximumSize(80,80);
                      Label_backImg->setPixmap(QPixmap(":/images/edit-icon.png").scaled (Label_backImg->width(),Label_backImg->height(),Qt::KeepAspectRatio));

                      QLabel *labelIcon = new QLabel(Label_backImg);
                      labelIcon->setGeometry(40,8,40,40);
                      labelIcon->setPixmap(QPixmap(":/images/notification.png").scaled (labelIcon->width(),labelIcon->height(),Qt::KeepAspectRatio));
                      

                      result image is :
                      0_1566199247348_Screenshot_2019-08-19_12-49-21.png

                      Hi, with this approach I will have to first create the axis externally and save them as some sort of a transparent image ?

                      A Offline
                      A Offline
                      anil_arise
                      wrote on 19 Aug 2019, 09:54 last edited by
                      #26

                      @r-p-h use only .png images

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        jhoney
                        Banned
                        wrote on 20 Aug 2019, 12:01 last edited by jhoney
                        #27
                        This post is deleted!
                        1 Reply Last reply
                        0
                        • P Pl45m4
                          12 Aug 2019, 15:22

                          @r-p-h

                          A ChartView, but as you already said, you have to create it on runtime, because it`s not a Widget in Qt Designer.

                          P Offline
                          P Offline
                          Pl45m4
                          wrote on 20 Aug 2019, 14:25 last edited by
                          #28

                          @pl45m4 said in Draw basic Axes on QPixmap ?:

                          A ChartView, but as you already said, you have to create it on runtime, because it`s not a Widget in Qt Designer.

                          @jhoney
                          I think @R-P-H doen't need the exact same answer again :)


                          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
                          0
                          • R Offline
                            R Offline
                            R-P-H
                            wrote on 21 Aug 2019, 16:38 last edited by
                            #29

                            Thanks for the support guys. I tried making a transparent QPixmap image using Qt::transparent fill for the axis and overlaying it onto my other QPixmap, however it didn't work properly. So I ended up just drawing directly onto the image itself. Not the most efficient method but it seems to work...

                            1 Reply Last reply
                            0

                            26/29

                            19 Aug 2019, 09:54

                            • Login

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