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. Document data in QPrintDialog

Document data in QPrintDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.2k 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.
  • H Offline
    H Offline
    HansBr
    wrote on last edited by HansBr
    #1

    Hello,
    how do I create a QPrintDialog that has the relevant information to print the document? My code at the moment is:

    /*!
     * send stuff to printer
     */
    void MainWin::print() {
        QPrinter printer;
        QPrintDialog prSettings(&printer, this);
    
        prSettings.setWindowTitle(tr("Print"));
    
        if(QDialog::Accepted == prSettings.exec()) {
            QPainter painter(&printer);
            m_ui.graphicsview->render(&painter);
        }
    }
    

    The final print output is as expected. But: I do not get any information about the print page count. Also the printer Properties window has a preview. The content of that is complete nonsense. It seems I have to connect the QGraphicsView somehow to the QPrintDialog before displaying it. How do I do this? None of the examples I have seen did it. Setting m_ui.graphicsview instead of this in the initialization does not change anything.

    Where I need that data is shown in that image:
    screenshot

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

      Hi
      Im not sure you can get to print in that preview window as it seems native.
      One can use
      http://doc.qt.io/qt-5/qprintpreviewdialog.html#details
      and its
      http://doc.qt.io/qt-5/qprintpreviewdialog.html#paintRequested
      signal to do the preview printing.
      To have Print Preview.

      H 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        Im not sure you can get to print in that preview window as it seems native.
        One can use
        http://doc.qt.io/qt-5/qprintpreviewdialog.html#details
        and its
        http://doc.qt.io/qt-5/qprintpreviewdialog.html#paintRequested
        signal to do the preview printing.
        To have Print Preview.

        H Offline
        H Offline
        HansBr
        wrote on last edited by
        #3

        @mrjj
        I see. But you have to understand that "I don't think it is possible" is not a satisfying answer to me.
        That thing is there and I have to access it. Or else it just seems buggy.

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

          Hi and welcome to devnet,

          Although I can understand you may not be satisfied, you have to understand that this is a community driven user forum.

          That said, you should provide more information:

          • What version of Qt are you using ?
          • What OS are you running ?
          • If Linux, what distribution ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          H 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi and welcome to devnet,

            Although I can understand you may not be satisfied, you have to understand that this is a community driven user forum.

            That said, you should provide more information:

            • What version of Qt are you using ?
            • What OS are you running ?
            • If Linux, what distribution ?
            H Offline
            H Offline
            HansBr
            wrote on last edited by
            #5

            @SGaist said in Document data in QPrintDialog:

            Although I can understand you may not be satisfied, you have to understand that this is a community driven user forum.

            I completely understand and meant no offence to @mrjj. I'm sorry if mrjj took it that way.

            That said, you should provide more information:

            • What version of Qt are you using ?
            • What OS are you running ?
            • If Linux, what distribution ?

            Qt Version is 5.5.1
            OS is Linux Mint 18.3 with Xfce.

            It seems none of the installed programs use that exact print dialog. So it might be better to not use QPrintDialog at all and create a custom print dialog?

            mrjjM 1 Reply Last reply
            0
            • H HansBr

              @SGaist said in Document data in QPrintDialog:

              Although I can understand you may not be satisfied, you have to understand that this is a community driven user forum.

              I completely understand and meant no offence to @mrjj. I'm sorry if mrjj took it that way.

              That said, you should provide more information:

              • What version of Qt are you using ?
              • What OS are you running ?
              • If Linux, what distribution ?

              Qt Version is 5.5.1
              OS is Linux Mint 18.3 with Xfce.

              It seems none of the installed programs use that exact print dialog. So it might be better to not use QPrintDialog at all and create a custom print dialog?

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

              @HansBr
              Oh, no offence taken. I was checking my mint linux if any app would actually render custom content in that mini preview.
              However, all print dialog i could find looked different and
              i assume you are using other desktop and im using XFCE so
              that is maybe why. but seems we have very similar setup except mine being mint 18.1
              Also as you noticed the other apps have different print dialogs
              so starting to wonder if the dialogs are native or 100% Qt made.

              1 Reply Last reply
              0
              • H Offline
                H Offline
                HansBr
                wrote on last edited by
                #7

                I found an application that uses this print window. The document viewer Okular. That is a KDE application.
                That means, for some reason Qt wants to use the KDE libraries even though XFCE is the active window manager.
                That preview widget in Okular looks exactly the same as in my example which leads me to believe that this print window is just broken. So I really don't know if I should use it or not.

                And then I still need to figure out the total page count.

                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