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. Printing multiline tickets

Printing multiline tickets

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.8k 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.
  • PayanAxP Offline
    PayanAxP Offline
    PayanAx
    wrote on last edited by
    #1

    Hi,

    I'm using a printer VKP80III to print tickets/recipes.
    And for now, the code look like this:

    QPrinterInfo _printer = ...;
    
    ...
    
    QPrinter printer(_printer);
    printer.setPaperSize(QSize(80, 120), QPrinter::Millimeter);
    printer.setPageMargins(15, 15, 15, 15, QPrinter::Millimeter);
    printer.setFullPage(true);
    
    QString tmp = message;
    tmp.replace("\n", "\r\n");
    
    QPainter painter;
    painter.begin(&printer);
    painter.setFont(QFont("Tahoma", 8));
    painter.drawText(QPoint(0, 0), tmp);
    painter.end();
    

    My paper is 80x120 mm.
    I expect an output like:

    --------------------------------
    ANY BANK
    --------------------------------
    TERMINAL #	123456
    SEQUENCE #	12345
    AUTH #	25688KK
    DATE 	11/11/2014
    TIME	16:52:24
    	
    CARD NUMBER	**** **** **** 0069
    	
    CUSTOMER NAME	BERNARD MADOFF
    	
    DISPENSED AMOUNT	$200.00
    REQUESTED AMOUNT	$200.00
    FROM ACCOUNT	CHECKING
    TERMINAL FEE	$1.00
    	
    TOTAL AMOUNT	$201.00
    BALANCE	$22,234,396.82
    
    
    --------------------------------.
    

    But only get this:

    -------------------------------- ANY BANK -------------------
    

    The rest doesn't print since it never go to a new line.
    Does anyone have a solution for this?

    Thanks in advance.

    ps: The ticket content is just a test, I'm not working for a bank.

    1 Reply Last reply
    0
    • Chris HennesC Offline
      Chris HennesC Offline
      Chris Hennes
      wrote on last edited by
      #2

      QPainter::drawText(const QPoint & position, const QString & text)
      does not support newlines, you need to use the
      void QPainter::drawText(const QRectF & rectangle, int flags, const QString & text)
      version of that function to get those to work.

      Chris Hennes, Pioneer Library System

      1 Reply Last reply
      3

      • Login

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