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. How to save the pixmap of QWidget without borders/ what is way we can save best quality image
Forum Updated to NodeBB v4.3 + New Features

How to save the pixmap of QWidget without borders/ what is way we can save best quality image

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 3.0k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on 20 Jun 2017, 13:44 last edited by Qt Enthusiast
    #1

    QPixmap * pixmap = new QPixMap(this->size())
    this render(pixmap)
    pixmap->save(fileName)

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 20 Jun 2017, 14:03 last edited by
      #2

      Not sure what the question is... QWidget::grab().save(fileName)

      P.S.
      Your code leaks memory

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 20 Jun 2017, 15:29 last edited by
        #3

        Hi
        What borders ?
        a widget don't have borders unless you do not give it a parent and it becomes a window?

        Q 1 Reply Last reply 20 Jun 2017, 16:01
        2
        • M mrjj
          20 Jun 2017, 15:29

          Hi
          What borders ?
          a widget don't have borders unless you do not give it a parent and it becomes a window?

          Q Offline
          Q Offline
          Qt Enthusiast
          wrote on 20 Jun 2017, 16:01 last edited by
          #4

          @mrjj borders means we are getting scrollbars

          M 1 Reply Last reply 20 Jun 2017, 16:19
          0
          • Q Qt Enthusiast
            20 Jun 2017, 16:01

            @mrjj borders means we are getting scrollbars

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 20 Jun 2017, 16:19 last edited by
            #5

            @Qt-Enthusiast

            Well if the widget has scrollbar shown, then render will also show them.
            You could disable the scrollbars.

            1 Reply Last reply
            4
            • Q Offline
              Q Offline
              Qt Enthusiast
              wrote on 21 Jun 2017, 14:11 last edited by Qt Enthusiast
              #6

              I have QGraphicsView and scene() is QGraphicsscene

              QRectF rect = scene()->sceneRect();
              QImage img(rect.width(),rect.height(), QImage::Format_RGB32);
              QPainter painter(&img);
              render(&painter); // , QRec

              how to save the pixmap without scrollbars . is it possible to get the pixmap of canvas without scrollbars how to get width of witdh of vertical and horizonal scrollbar so that I can get only rectangle for Canvas without scrollbar

              V 1 Reply Last reply 21 Jun 2017, 15:16
              0
              • Q Qt Enthusiast
                21 Jun 2017, 14:11

                I have QGraphicsView and scene() is QGraphicsscene

                QRectF rect = scene()->sceneRect();
                QImage img(rect.width(),rect.height(), QImage::Format_RGB32);
                QPainter painter(&img);
                render(&painter); // , QRec

                how to save the pixmap without scrollbars . is it possible to get the pixmap of canvas without scrollbars how to get width of witdh of vertical and horizonal scrollbar so that I can get only rectangle for Canvas without scrollbar

                V Offline
                V Offline
                VRonin
                wrote on 21 Jun 2017, 15:16 last edited by
                #7

                @Qt-Enthusiast said in How to save the pixmap of QWidget without borders:

                how to get width of witdh of vertical and horizonal scrollbar so that I can get only rectangle for Canvas without scrollbar

                • verticalScrollBar()->width()
                • horizontalScrollBar()->width()

                Of course you'll have to make sure they are visible first

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  Qt Enthusiast
                  wrote on 21 Jun 2017, 15:36 last edited by
                  #8

                  how to do that

                  Q 1 Reply Last reply 21 Jun 2017, 15:38
                  0
                  • Q Offline
                    Q Offline
                    Qt Enthusiast
                    wrote on 21 Jun 2017, 15:36 last edited by Qt Enthusiast
                    #9

                    what is way we can save best quality image

                    1 Reply Last reply
                    0
                    • Q Qt Enthusiast
                      21 Jun 2017, 15:36

                      how to do that

                      Q Offline
                      Q Offline
                      Qt Enthusiast
                      wrote on 21 Jun 2017, 15:38 last edited by
                      #10

                      @Qt-Enthusiast isVisible function

                      1 Reply Last reply
                      0

                      7/10

                      21 Jun 2017, 15:16

                      • Login

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