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. Qt6 Printing in Landscape
Forum Updated to NodeBB v4.3 + New Features

Qt6 Printing in Landscape

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 343 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.
  • J Offline
    J Offline
    Jose E
    wrote on last edited by Jose E
    #1

    This code was working in Qt5:

    #include <QApplication>
    #include <QPrinter>
    #include <QPainter>
    
    int main(int argc, char *argv[]) {
        QApplication app(argc, argv);
    
        QPrinter printer;
        printer.setPageOrientation(QPageLayout::Landscape);
    
        QPainter painter(&printer);
        painter.drawText(100, 100, "¡Hola, mundo!, ¿que tal estan ustedes?");
        painter.end();
    
        return 0;
    }
    

    I mean that having an A4 loaded in the printer in a potrait position, the system rotated the printout to show it in landscape format. This code in Qt6 does not rotate the text and prints it outside the margin, the same thing happens using PageLayout which seems the right direction for Qt6:

    #include <QApplication>
    #include <QPrinter>
    #include <QPainter>
    #include <QPageLayout>
    
    int main(int argc, char *argv[]) {
        QApplication app(argc, argv);
    
        QPrinter printer;
        
        QPageLayout pageLayout = printer.pageLayout();
        pageLayout.setOrientation(QPageLayout::Landscape);
        printer.setPageLayout(pageLayout);
    
        QPainter painter(&printer);
        painter.drawText(100, 100, "¡Hola, mundo!, ¿qué tal están ustedes?");
        painter.end();
    
        return 0;
    }
    

    How should we maintain this functionality, without resorting to manual rotation?

    By the way, if print to a PDF printer it works fine in all cases and my Qt is 6.4.2 running in ubuntu.

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

      Hi and welcome to devnet,

      It looks like it could be a regression. Can you test with a more recent version of Qt ? The current series is 6.7 with 6.8 around the corner.

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

      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