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 print contents from stackedWidget with QPrinter
Qt 6.11 is out! See what's new in the release blog

How to print contents from stackedWidget with QPrinter

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 996 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.
  • L Offline
    L Offline
    LT-K101
    wrote on last edited by
    #1

    Hi, is it possible to print contents from two multiple stackedWidget pages using QPrinter. And if it's possible how do I go about it, any assistance is appreciated. This is my first time using QPrinter.

    artwawA 1 Reply Last reply
    0
    • L LT-K101

      Hi, is it possible to print contents from two multiple stackedWidget pages using QPrinter. And if it's possible how do I go about it, any assistance is appreciated. This is my first time using QPrinter.

      artwawA Offline
      artwawA Offline
      artwaw
      wrote on last edited by
      #2

      @LT-K101 Please clarify, you mean the content/values held in the widgets of the stack or more like a screenshot of it?

      For more information please re-read.

      Kind Regards,
      Artur

      L 1 Reply Last reply
      1
      • artwawA artwaw

        @LT-K101 Please clarify, you mean the content/values held in the widgets of the stack or more like a screenshot of it?

        L Offline
        L Offline
        LT-K101
        wrote on last edited by LT-K101
        #3

        @artwaw yes please, I have a stackedWiget with (3 pages) and I would like to print all the contents and values of the stackedWiget altogether on an A4 using a printer.

        artwawA JonBJ 2 Replies Last reply
        0
        • L LT-K101

          @artwaw yes please, I have a stackedWiget with (3 pages) and I would like to print all the contents and values of the stackedWiget altogether on an A4 using a printer.

          artwawA Offline
          artwawA Offline
          artwaw
          wrote on last edited by
          #4

          @LT-K101 You just have to iterate over the widgets and do it mostly by hand I am afraid, and construct everything.

          if you fancy nice output you can create rich text document (iterating over values and adding html subset elements to one QString, then using QTextDocument::setHtml() with said QString so it is all nicely laid down on pages and QTextDocument::print() to actually print it) or if not, any example of QPrinter printing regular text will do.

          Rich Text Processing overview is here https://doc.qt.io/qt-5/richtext.html

          But there is no explicit way to gather the data automatically from stacked widget I am afraid.

          For more information please re-read.

          Kind Regards,
          Artur

          1 Reply Last reply
          3
          • L LT-K101

            @artwaw yes please, I have a stackedWiget with (3 pages) and I would like to print all the contents and values of the stackedWiget altogether on an A4 using a printer.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @LT-K101
            You can go down @artwaw's way of creating a document from your data and printing that. But it's quite a lot of work.

            Are you instead just wanting to print/paint a "screenshot" of each page (just like it looks on screen) on the printer?

            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