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 duplex print?
Qt 6.11 is out! See what's new in the release blog

How to duplex print?

Scheduled Pinned Locked Moved General and Desktop
14 Posts 2 Posters 3.2k 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.
  • A Offline
    A Offline
    AlexxanderX
    wrote on last edited by
    #1

    I want to print with a duplex printer, but I want to print directly from code, without the printer dialog. I have Qt 5.4. From what I see there is no more a setDoubleSidedPrinting(), but my code still compile. I tried with setDoubleSidedPrinting(true) and also with setDuplex(QPrinter::DuplexAuto) but the printer doesn't print duplex. Maybe is the problem I write the pages: I have 2 pages and after the first page I call newPage().
    @void printPage()
    {
    QPainter painter(m_printer);
    making some settings
    page.mainFrame()->render(&painter); // page is QWebPage
    }

    void mainFunction()
    {
    printPage();
    m_printer->newPage();
    printPage();
    }@

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

      Hi,

      I'm not sure I'm following you. Why would you need to set that ?

      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
      • A Offline
        A Offline
        AlexxanderX
        wrote on last edited by
        #3

        I updated the first post. I only want to print a double sided page/duplex directly/without using print dialog.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AlexxanderX
          wrote on last edited by
          #4

          I updated the first post. I only want to print a double sided page/duplex directly/without using print dialog.

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

            Did you check that you are trying to use the correct printer ?

            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
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Did you check that you are trying to use the correct printer ?

              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
              • A Offline
                A Offline
                AlexxanderX
                wrote on last edited by
                #7

                Yes, and I will make a check function for it. But the code is right?

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AlexxanderX
                  wrote on last edited by
                  #8

                  Yes, and I will make a check function for it. But the code is right?

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

                    How do you create m_printer ?

                    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
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      How do you create m_printer ?

                      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
                      • A Offline
                        A Offline
                        AlexxanderX
                        wrote on last edited by
                        #11

                        @m_printer = new QPrinter(QPrinter::HighResolution);
                        m_printer->setPageSize(QPageSize(QPageSize::A4));
                        m_printer->setOrientation(QPrinter::Portrait);
                        m_printer->setPageMargins(QMarginsF(20.f,20.f,10.f,10.f));@

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          AlexxanderX
                          wrote on last edited by
                          #12

                          @m_printer = new QPrinter(QPrinter::HighResolution);
                          m_printer->setPageSize(QPageSize(QPageSize::A4));
                          m_printer->setOrientation(QPrinter::Portrait);
                          m_printer->setPageMargins(QMarginsF(20.f,20.f,10.f,10.f));@

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

                            You should rather use the second constructor using QPrinterInfo to ensure you are using the right device

                            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
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              You should rather use the second constructor using QPrinterInfo to ensure you are using the right device

                              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

                              • Login

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