从条形码读取作为一个输入

时间:2013-10-07 01:06:30

标签: qt4 barcode barcode-scanner

我遇到了textChanged()信号的问题,基本上我正在阅读条形码但不幸的是我读取条形码作为一系列输入,使textChanged()多次发出。在stackoverflow上搜索给我这两个问题:C# WinForm + Barcode Scanner input, TextChanged ErrorDetecting when a barcode scanner ends input,第一个解决方案我无法传输代码以使其适用于我(我不用C#编写代码),以及第二个听起来很容易,但我没有用我的应用程序读取结束行:

connect(ui-> matEdit,SIGNAL(textChanged(QString)),this,SLOT(GetEmployee(QString)));

void EmployeeDayLogger::GetEmployee(QString id)
{
    char c = id.toAscii();
    if(c == '\n')
    {

编译输出:

..\..\..\Qt\Qt4.8.3\include/QtCore/../../src/corelib/tools/qbytearray.h: In member function 'void EmployeeDayLogger::GetEmployee(QString)':
..\..\..\Qt\Qt4.8.3\include/QtCore/../../src/corelib/tools/qbytearray.h:383: error: 'QByteArray::operator QNoImplicitBoolCast() const' is private
..\employeedaylogger.cpp:152: error: within this context

1 个答案:

答案 0 :(得分:0)

由于您的文字字段最有可能包含整个条形码,请尝试:

if (id.endsWith('\n'))
相关问题