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

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
  • 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 last edited by Qt Enthusiast
    #1

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

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on 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
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on 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
        2
        • mrjjM mrjj

          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 last edited by
          #4

          @mrjj borders means we are getting scrollbars

          mrjjM 1 Reply Last reply
          0
          • Q Qt Enthusiast

            @mrjj borders means we are getting scrollbars

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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 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

              VRoninV 1 Reply Last reply
              0
              • Q Qt Enthusiast

                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

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on 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 last edited by
                  #8

                  how to do that

                  Q 1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    Qt Enthusiast
                    wrote on last edited by Qt Enthusiast
                    #9

                    what is way we can save best quality image

                    1 Reply Last reply
                    0
                    • Q Qt Enthusiast

                      how to do that

                      Q Offline
                      Q Offline
                      Qt Enthusiast
                      wrote on last edited by
                      #10

                      @Qt-Enthusiast isVisible function

                      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