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. QPrintDialog / QPrintPreviewWidget Interaction

QPrintDialog / QPrintPreviewWidget Interaction

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 416 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
    Adam Crowe
    wrote on last edited by
    #1

    Hello!

    Does QPrintDialog interact with a QPrintPreviewWidget?

    I have a QPrintPreviewWidget which draws everything I need it to draw across a few pages. Before printing, I launch a QPrintDialog and pass on QPrinter object. And I then run QPrintPreivewWidget::print().

    I assumed, QPrintDialog changes the settings in the QPrinter object (like page from/to) so the print function would take these changed into effect, but it seems the settings of QPrintPreviewWidget are independent? And if it is, do I have to manually only print the selected pages or is there an automatic way to specify the range?

    Thank you!

    jsulmJ 1 Reply Last reply
    0
    • A Adam Crowe

      Hello!

      Does QPrintDialog interact with a QPrintPreviewWidget?

      I have a QPrintPreviewWidget which draws everything I need it to draw across a few pages. Before printing, I launch a QPrintDialog and pass on QPrinter object. And I then run QPrintPreivewWidget::print().

      I assumed, QPrintDialog changes the settings in the QPrinter object (like page from/to) so the print function would take these changed into effect, but it seems the settings of QPrintPreviewWidget are independent? And if it is, do I have to manually only print the selected pages or is there an automatic way to specify the range?

      Thank you!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Adam-Crowe said in QPrintDialog / QPrintPreviewWidget Interaction:

      I launch a QPrintDialog and pass on QPrinter object. And I then run QPrintPreivewWidget::print().

      Do you pass the same QPrint object also to QPrintPreivewWidget?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Adam Crowe
        wrote on last edited by
        #3

        Hi @jsulm,

        This whole question started when I tried to set the to/from page range for printing. The only other time I did this sort of printing was in C# on .Net where the print dialog automatically prints the pages you ask it to print. When QPrintDialog didn't do that, I started wondering how much it actually controls.

        I couldn't find much online about this. All the examples online print text directly from a QTextEdit or similar widget which makes controlling pages very straightforward, but I'm drawing something quite complicated so it wasn't as straightforward. It would have been very convenient to draw everything and let QPrintDialog send the relevant pages to the printer like .Net does.

        After some experimentation, I figured out that the QPrinterDialog does change the settings of the QPrinter object you pass to it but that's it. It doesn't control the printing process at all. I had to implement that functionality myself.

        Please note that I only use QPrintPreviewWidget to show the preview on the screen. I don't use it to print because it prints the whole preview no matter what! Instead I render the same drawing again directly to the QPrinter.

        It's a bit convoluted but I suppose printing is :-/

        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