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. Qprinter take receipt
QtWS25 Last Chance

Qprinter take receipt

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 3.2k 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.
  • S Offline
    S Offline
    saravanavelu39
    wrote on 6 Aug 2014, 11:57 last edited by
    #1

    Hi all,

          I need to take a print receipt. I have one string "hello",,and how to take this value from print receipt using Qprinter,,please give me suggesstion,, Thanks
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      saravanavelu39
      wrote on 6 Aug 2014, 12:03 last edited by
      #2

      This is my code
      @QESCPOS printer("/dev/ttyUSB0");

      printer.open(QIODevice::ReadWrite);
      printer.autoConfig();
      
      /*printer.setBaudRate(BAUD19200);
      printer.setFlowControl(FLOW_HARDWARE);
      printer.setParity(PAR_NONE);
      printer.setCharacterCodeTable(QESCPOS::CCT_PC850);
      printer.setInternationalCharacterSet(QESCPOS::ICS_CHINESE);
      
      
      
      printer.initialize();*/
      

      // printer.cutPaper(true, 0);

      /*QList<QImage> l;
      l.append(QImage("/home/qdot/Downloads/logo.png"));
      printer.defineNVRaster(l);*/
      
      printer.write("Test: 大虾多士\n");
      printer.cutPaper(true, 0);@
      

      in here i need to display (" Test: 大虾多士\n") in the receipt,,please give me a suggesstion

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 6 Aug 2014, 12:36 last edited by
        #3

        Hi,

        What is QESCPOS ? How is it related to QPrinter ? What do you get ?

        You need to give more informations

        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
        • S Offline
          S Offline
          saravanavelu39
          wrote on 7 Aug 2014, 09:50 last edited by
          #4

          Hi,
          I have the chinese character problem same like this link "https://bugreports.qt-project.org/browse/QTBUG-27508": ,, i have the problem same like as the first diagram,,, the chinese characters are ovarlapped in the receipt,,,but it comes correctly in the widget,,,please give me a good suggesstion,,thanks

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 7 Aug 2014, 20:25 last edited by
            #5

            I can't give you any suggestions if you don't answer my questions first

            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
            • S Offline
              S Offline
              saravanavelu39
              wrote on 8 Aug 2014, 07:17 last edited by
              #6

              Hi,

                Actually QESCPOS is a third party file,,,i just inherit that mt project,,,my problem is I send the chinese character in the Qprinter means chinese characters are not displayed corretly in the print receipt,,,But if i pass the chinese character in the button means it displayed correctly,,,this is the my problem,,,,please give any suggesstion,,,thanks,,
              
              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 13 Aug 2014, 21:55 last edited by
                #7

                Which version of Qt are you using ? If you print ASCII char, does it work correctly ?

                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
                • S Offline
                  S Offline
                  saravanavelu39
                  wrote on 14 Aug 2014, 09:47 last edited by
                  #8

                  Hi SGaist,,,I am using Qt 4.8.6,, if i print ascii character means it comes correctly,,, If i print the chinese character means the characters are broken,,

                  here is my code,
                  @@QString ItemPushButton::name_check(QString str)
                  {
                  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
                  QRegExp [removed]"#([0-9]+);");
                  QStringList list,list1;
                  int pos = 0;
                  int length;
                  while((pos = expression.indexIn(str,pos))!=-1)
                  {
                  list << expression.cap(1);
                  QString v;
                  length = expression.matchedLength();
                  v=str.mid(pos+1,length-1-1);
                  QByteArray ba = v.toUtf8();
                  QString str1 = QString(QChar(v.toInt()));
                  list1 <<str1;
                  pos += expression.matchedLength();
                  }
                  foreach (QString s, list) {
                  str.replace(s,"");
                  }
                  str = str.replace("#","");
                  str = str.replace(";","");

                  foreach (QString s, list1) {
                      str = str.append(s);
                  }
                  return str;
                  

                  }@

                  for example if i send (#26434;) string in this function means it retuns chinese character string,,after that i pass this string to pushbutton means it displayed correctly,,but if i pass the chinese character in Qprinter means the characters are broken in the receipt,,please give me a suggesstion,,Thanks,,

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 19 Aug 2014, 22:43 last edited by
                    #9

                    Then you should ask the status of this on the bug report

                    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

                    4/9

                    7 Aug 2014, 09:50

                    • Login

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