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. Print from qtablewidget
Qt 6.11 is out! See what's new in the release blog

Print from qtablewidget

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 5.3k Views 1 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      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
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          Have you visit link above?

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qxoz
            wrote on last edited by
            #5

            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
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              tnx for now,I'll do it

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                [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
                0

                • Login

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