Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Help with printing Qpixmap

    General and Desktop
    2
    5
    3168
    Loading More Posts
    • 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.
    • B
      buddha last edited by

      i want to print out Qtableview in QPrintPreviewDialog and this is my code .
      but in QPrintPreviewDialog it show very small
      "picture of my QPrintPreviewDialog ":http://www.xum.ir/images/2014/05/22/print.png
      any body can help me?
      @
      void Report::filePrintPreview(){
      #ifndef QT_NO_PRINTER
      QPrinter printer(QPrinter::HighResolution);
      QPrintPreviewDialog preview(&printer, this);
      preview.setWindowFlags ( Qt::Window );
      connect(&preview, SIGNAL(paintRequested(QPrinter*)), SLOT(printPreview(QPrinter *)));
      preview.exec();
      #endif
      }

      void Report::printPreview(QPrinter *printer){
      QPixmap pixmap(ui->tableView->size());
      ui->tableView->render(&pixmap);
      QPainter painter;
      painter.begin(printer);//p is my QPrinter
      printer->paintEngine()->drawPixmap(QRectF(0, 0, pixmap.width(), pixmap.height()), pixmap, QRectF(0, 0,pixmap.width(), pixmap.height()));
      painter.end();
      }
      @

      1 Reply Last reply Reply Quote 0
      • B
        buddha last edited by

        any body can't help me?
        pleeeeeas

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi,

          Have a look "here":http://qt-project.org/doc/qt-5/qtprintsupport-index.html#printing-widgets

          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 Reply Quote 0
          • B
            buddha last edited by

            [quote author="SGaist" date="1400794409"]Hi,

            Have a look "here":http://qt-project.org/doc/qt-5/qtprintsupport-index.html#printing-widgets[/quote]

            I've read this before,
            If possible, read and then answer a question.

            1 Reply Last reply Reply Quote 0
            • B
              buddha last edited by

              No one could answer my question?

              1 Reply Last reply Reply Quote 0
              • First post
                Last post