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 use use Generic/Text only printers with Qt? (Both Linux and Windows)
QtWS25 Last Chance

How to use use Generic/Text only printers with Qt? (Both Linux and Windows)

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.9k 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.
  • MucipM Offline
    MucipM Offline
    Mucip
    wrote on last edited by
    #1

    Hi,
    I need to use dot matrix printer in my Qt program. But there is limited resources about printing. By the way all the documents and samples for graphic printing.
    I set the Epson LX-300 printer as Generic/Text only printer on Win 10. But I can not use it with below code. Page is empty. I need to print invoice line by line. Not as graphic like pdf or any others.

    void MainWindow::on_pushButton_4_clicked()
    {

    QTextDocument doc;
         doc.setHtml( "<p>A QTextDocument can be used to present formatted text "
                      "in a nice way.</p>"
                      "<p align=center>It can be <b>formatted</b> "
                      "<font size=+2>in</font> <i>different</i> ways.</p>"
                      "<p>The text can be really long and contain many "
                      "paragraphs. It is properly wrapped and such...</p>" );
          QPrinter printer;         
          doc.print(&printer);
    

    }

    P.S. I need to use my program on both Linux and Windows platforms. So it must be good solution for the both of these if possible...
    Regards,
    Mucip:)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you try to use QPrintPreviewDialog to see what you should get ?

      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
      0
      • MucipM Offline
        MucipM Offline
        Mucip
        wrote on last edited by
        #3

        Hi,
        Unfortunately I am still trying to understand QPrintPreviewDialog mechanism! And I can not find a enough time today.
        But in any case, with the same code I can write Epson LX-350 printer on windows platform. I can see this on the page.
        But the paper comes empty when I set the default printer as Generic/Text.

        By the way, Is there a tool like FastReport with Qt? Because FastReport was printing on the dot matrix printers too.

        P.S.: I will send the result here when I test with QPrintPreviewDialog.

        Regards,
        Mucip:)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          There are several: QtRPT, CuteReport, LimeReport, NCReport etc.

          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
          0
          • MucipM Offline
            MucipM Offline
            Mucip
            wrote on last edited by
            #5

            Hi,
            But I think none of them are open-source.

            Regards,
            Mucip:)

            1 Reply Last reply
            0
            • MucipM Offline
              MucipM Offline
              Mucip
              wrote on last edited by
              #6

              Hi,
              I will try this way:
              I will make all output as pdf file like below way,

              printer.setOutputFormat(QPrinter::PdfFormat);
              printer.setOutputFileName("test.pdf");
              printer.setPaperSize(QSizeF(2, 2), QPrinter::Inch);
              

              I will try to change paper size because I need to use Width 15cm x Hight 16 cm continuous form. I hope this will solve my problem. So I do not need to use Generic/text only printer if I can change the paper size in QT while sending the document. Because I don't know why but I can not change the paper size of Epson LX-350 in windows control panel. But I can change other printers like Canon. This is really strange!... :(

              Regards,
              Mucip:)

              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