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 change FontSize at print
Qt 6.11 is out! See what's new in the release blog

How change FontSize at print

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 386 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    How change FontSize at print?
    It's not work:

    void MainWindow::PrintDocument(QString &TextForPrint) //PrintDocument
    {
        QPrinter MyPrinter;
        QPrintDialog *PrinterDialog = new QPrintDialog(&MyPrinter);
        PrinterDialog->setWindowTitle("Print");
        QFont FontForPrint;
        FontForPrint.setPointSize(22);
        //PrinterDialog->setFont(FontForPrint);
        if (PrinterDialog->exec())
        {
            QPainter MyPainter;
            MyPainter.begin(&MyPrinter);
            MyPainter.drawText(100, 100, 400, 400, Qt::AlignLeft|Qt::AlignTop, TextForPrint);
            MyPainter.setFont(FontForPrint);
            MyPainter.end();
        }
    }
    
    RatzzR 1 Reply Last reply
    0
    • M Mikeeeeee

      Hi!
      How change FontSize at print?
      It's not work:

      void MainWindow::PrintDocument(QString &TextForPrint) //PrintDocument
      {
          QPrinter MyPrinter;
          QPrintDialog *PrinterDialog = new QPrintDialog(&MyPrinter);
          PrinterDialog->setWindowTitle("Print");
          QFont FontForPrint;
          FontForPrint.setPointSize(22);
          //PrinterDialog->setFont(FontForPrint);
          if (PrinterDialog->exec())
          {
              QPainter MyPainter;
              MyPainter.begin(&MyPrinter);
              MyPainter.drawText(100, 100, 400, 400, Qt::AlignLeft|Qt::AlignTop, TextForPrint);
              MyPainter.setFont(FontForPrint);
              MyPainter.end();
          }
      }
      
      RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by Ratzz
      #2

      @Mikeeeeee said in How change FontSize at print:

      It's not work:

      Does it change the font ? then u have to take font from QPrinter and then try to modify font.
      Something like this

      QFont font = MyPrinter.font() ;
      

      --Alles ist gut.

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

        Hi
        You set font After you draw the text.

        1 Reply Last reply
        2

        • Login

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