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. Simple QTextEdit printing!

Simple QTextEdit printing!

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

    Hello.. What is the correct way to print the content of a QTextEdit without margins in QT5.14.2?

    I'm trying this way:

    ```
    

    QPrinter *printer = new QPrinter();
    printer->setPageSize( QPageSize( QPageSize::A4 ) );
    printer->setPageMargins( 0, 0, 0, 0, QPrinter::Millimeter );
    printer->setOutputFormat(QPrinter::NativeFormat);
    QPrintDialog *dlg = new QPrintDialog(printer, this);
    if (dlg->exec() == QDialog::Accepted) {
    TE_Rel->document()->print(printer);
    }

    
    But this is not respecting the function of putting 0 of margin.
    
    Something is missing?
    JonBJ 1 Reply Last reply
    0
    • R RenanHm

      Hello.. What is the correct way to print the content of a QTextEdit without margins in QT5.14.2?

      I'm trying this way:

      ```
      

      QPrinter *printer = new QPrinter();
      printer->setPageSize( QPageSize( QPageSize::A4 ) );
      printer->setPageMargins( 0, 0, 0, 0, QPrinter::Millimeter );
      printer->setOutputFormat(QPrinter::NativeFormat);
      QPrintDialog *dlg = new QPrintDialog(printer, this);
      if (dlg->exec() == QDialog::Accepted) {
      TE_Rel->document()->print(printer);
      }

      
      But this is not respecting the function of putting 0 of margin.
      
      Something is missing?
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @RenanHm
      I am guessing: you have set the printer's margins to 0, but the QTextDocument has its own setDocumentMargin(qreal margin) which it says defaults to 4. If that is what you are seeing do you want to set that to 0 too?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RenanHm
        wrote on last edited by
        #3

        Yes.. but I've also tried:

            TE_Rel->document()->setDocumentMargin(0);
        

        It has no effect.

        I'm migrating from QT4 to QT5 and I'm having trouble printing.

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

          Hi
          Most printers have a non printable margin unless its a label printer.
          Is it the same printer as with the Qt4 app and now the same code is showing a margin or
          its it also another printer you test with ?

          R 1 Reply Last reply
          0
          • mrjjM mrjj

            Hi
            Most printers have a non printable margin unless its a label printer.
            Is it the same printer as with the Qt4 app and now the same code is showing a margin or
            its it also another printer you test with ?

            R Offline
            R Offline
            RenanHm
            wrote on last edited by
            #5

            @mrjj I'm migrating QT4 to QT5... same code and same printer. But different results. Placing a simple margin on QT5 is very difficult. Something that was supposed to be done in minutes is now turning into days. No solution at the moment. Almost giving up on migrating to QT5.

            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