Results 1 to 2 of 2

Thread: Printing from TextEdit | QPrinter | QPrintDialog

  1. #1
    Join Date
    May 2013
    Posts
    11
    Thanks
    1
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Lightbulb Printing from TextEdit | QPrinter | QPrintDialog

    Hi,

    I am trying to get printing service to work in my simple program. I am doing it in this way:

    Qt Code:
    1. #include <QtPrintSupport/QPrintDialog>
    2. #include <QtPrintSupport/QPrinter>
    To copy to clipboard, switch view to plain text mode 

    And than I get the code in my print button.

    Qt Code:
    1. void MainWindow::on_printButton_clicked()
    2. {
    3. QPrinter printer;
    4. QPrintDialog printDialog(&printer, this);
    5. if (printDialog.exec() == QDialog::Accepted) {
    6. ui->textBox->print(&printer);
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    I get a lot of "undefined reference" errors to QPrintDialog and QPrinter.
    If You could drop me some hint.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Printing from TextEdit | QPrinter | QPrintDialog

    Your includes:
    Qt Code:
    1. #include <QPrintDialog>
    2. #include <QPrinter>
    To copy to clipboard, switch view to plain text mode 
    Your PRO file:
    Qt Code:
    1. QT += printsupport
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Printing QwtPlot on QPrinter
    By gkarthick5 in forum Qwt
    Replies: 5
    Last Post: 28th June 2011, 12:33
  2. Printing from a textEdit
    By Nefastious in forum Newbie
    Replies: 2
    Last Post: 21st October 2009, 05:29
  3. Safe checking the QPrinter::PrintState after printing
    By mSergey in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2008, 16:37
  4. Printing via QPrinter doesnt work
    By mSergey in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2008, 19:00
  5. How to use QPrinter without QPrintDialog?
    By pascal456 in forum Qt Programming
    Replies: 2
    Last Post: 15th November 2006, 19:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.