Qt Forum

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

    Print from qtablewidget

    General and Desktop
    2
    7
    4505
    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

      Hi everybody
      i am ab beginning in Qt and have a question about it. i am store some data from database in to a QTableWidget.
      in my project i want to print from a QTableWidgetbut i don't know how i can do that. is there ant solution or example code to help me.
      tanx.

      1 Reply Last reply Reply Quote 0
      • Q
        qxoz last edited by

        Before give you an advice, we should know where are you now? Do you write some code? Did you try print something? Have you specific problem or it is a general question?
        Maybe a start point: "Qt Print Support":http://qt-project.org/doc/qt-5/qtprintsupport-index.html

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

          yes,i try to print this QTableWidget but i don't know how print some thing in Qt, can you give me an example that print in Qt?

          1 Reply Last reply Reply Quote 0
          • Q
            qxoz last edited by

            Have you visit link above?

            1 Reply Last reply Reply Quote 0
            • Q
              qxoz last edited by

              Take a look to "Font Sampler Example":http://qt-project.org/doc/qt-4.8/painting-fontsampler.html . It comes with QtSDK installer.

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

                tnx for now,I'll do it

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

                  [quote author="qxoz" date="1400502862"]Take a look to "Font Sampler Example":http://qt-project.org/doc/qt-4.8/painting-fontsampler.html . It comes with QtSDK installer.[/quote]

                  i work to print a widget in Qt and finally this is my code, and i have a problem,
                  my widget show very small in QPrintPreviewDialog,you can show it in this link ("my QPrintPreviewDialog picture":http://www.xum.ir/images/2014/05/22/print.png )
                  pelase help me i need it

                  @ 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
                  • First post
                    Last post