0

我的textChanged()信号有问题,基本上我是从条码读取的,但不幸的是,我的读取条码是因为一系列输入女巫textChanged()多次发出。在 stackoverflow 上搜索给了我这两个问题:C# WinForm + Barcode Scanner input, TextChanged ErrorDetecting when a barcode scanner ends input,第一个解决方案我无法传输代码以使其对我有用(我不编码在 C# 中),第二个听起来很简单,但我无法阅读我的应用程序的结尾行:

连接(ui->matEdit,SIGNAL(textChanged(QString)),这个,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
4

1 回答 1

0

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

if (id.endsWith('\n'))
于 2013-10-13T13:04:44.417 回答