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. QPrinter initialization
Forum Updated to NodeBB v4.3 + New Features

QPrinter initialization

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 893 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.
  • mads-lM Offline
    mads-lM Offline
    mads-l
    wrote on last edited by
    #1

    Hello,

    What is the difference of these two sequences initializing the QPrinter?

    1. Using QPrinterinfo directly without any dialog:

      QPrinterInfo printerInfo = QPrinterInfo::printerInfo("Printer NN");
      QPrinter printer(printerInfo,QPrinter::HighResolution);

    2. Using QPrintDialog to select the printer:

      QPrinter printer(QPrinter::HighResolution);
      QPrintDialog dialog(&printer, this);
      if (dialog.exec() != QDialog::Accepted)
      return;

    When printing, I experience that method number 2 works as expected, while method number 1 is stretching the output horizontally.
    In this case I would prefere to print without an extra dialog, but cannot figure out what "magic" the QPrintDialog does to my QPrinter.

    jsulmJ aha_1980A 2 Replies Last reply
    0
    • mads-lM mads-l

      Hello,

      What is the difference of these two sequences initializing the QPrinter?

      1. Using QPrinterinfo directly without any dialog:

        QPrinterInfo printerInfo = QPrinterInfo::printerInfo("Printer NN");
        QPrinter printer(printerInfo,QPrinter::HighResolution);

      2. Using QPrintDialog to select the printer:

        QPrinter printer(QPrinter::HighResolution);
        QPrintDialog dialog(&printer, this);
        if (dialog.exec() != QDialog::Accepted)
        return;

      When printing, I experience that method number 2 works as expected, while method number 1 is stretching the output horizontally.
      In this case I would prefere to print without an extra dialog, but cannot figure out what "magic" the QPrintDialog does to my QPrinter.

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

      @mads-l When using QPrintDialog you should use the printer user selected/configured in the dialog (http://doc.qt.io/qt-5/qprintdialog.html#printer). Do you?

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

      mads-lM 1 Reply Last reply
      3
      • mads-lM mads-l

        Hello,

        What is the difference of these two sequences initializing the QPrinter?

        1. Using QPrinterinfo directly without any dialog:

          QPrinterInfo printerInfo = QPrinterInfo::printerInfo("Printer NN");
          QPrinter printer(printerInfo,QPrinter::HighResolution);

        2. Using QPrintDialog to select the printer:

          QPrinter printer(QPrinter::HighResolution);
          QPrintDialog dialog(&printer, this);
          if (dialog.exec() != QDialog::Accepted)
          return;

        When printing, I experience that method number 2 works as expected, while method number 1 is stretching the output horizontally.
        In this case I would prefere to print without an extra dialog, but cannot figure out what "magic" the QPrintDialog does to my QPrinter.

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @mads-l how is this topic different from https://forum.qt.io/topic/97637/qprinter-the-output-becomes-stretched ?

        Qt has to stay free or it will die.

        mads-lM 1 Reply Last reply
        1
        • jsulmJ jsulm

          @mads-l When using QPrintDialog you should use the printer user selected/configured in the dialog (http://doc.qt.io/qt-5/qprintdialog.html#printer). Do you?

          mads-lM Offline
          mads-lM Offline
          mads-l
          wrote on last edited by
          #4

          @jsulm I do, and it is working fine in this situation. I am using a label printer, and the size of the label is according to the properties of the setup in the printer driver. When using the QPrinterInfo with the name of the printer in the QPrinter constructor it fails.

          1 Reply Last reply
          0
          • aha_1980A aha_1980

            @mads-l how is this topic different from https://forum.qt.io/topic/97637/qprinter-the-output-becomes-stretched ?

            mads-lM Offline
            mads-lM Offline
            mads-l
            wrote on last edited by
            #5

            @aha_1980 I am working with the same problem, but this is a more generalized presentation of the problem.

            mrjjM 1 Reply Last reply
            0
            • mads-lM mads-l

              @aha_1980 I am working with the same problem, but this is a more generalized presentation of the problem.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @mads-l
              Hi
              You can check out what QPrintDialog does via
              https://code.woboq.org/qt5/qtbase/src/printsupport/dialogs/
              all code is hot linked so its easy to navigate.

              1 Reply Last reply
              1

              • Login

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