Qprinter take receipt



  • 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


  • 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


  • Lifetime Qt Champion

    Hi,

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

    You need to give more informations



  • 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


  • Lifetime Qt Champion

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



  • 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,,

  • Lifetime Qt Champion

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



  • 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,,


  • Lifetime Qt Champion

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.