16,213
社区成员
发帖
与我相关
我的任务
分享
///////////////////////////////////////////////////////////
//常量定义
#define STR_TOTALLINE_TYPE_USER QString::fromUtf8("内线")
#define STR_TOTALLINE_TYPE_TRUNK QString::fromUtf8("外线")
#define STR_TOTALLINE_TYPE_EMPTY QString::fromUtf8("悬空")
#define STR_TOTALLINE_TYPE_RECORD QString::fromUtf8("录音")
///////////////////////////////////////////////////////////
//signal 定义
signals:
void outTableItem(int nRow, int nCol, QString label);
////////////////////////////////////////////////////////////
//signal 使用
long lType;
QString strText;
/*usTotalLine > 8*/
for (int i = 0; i < usTotalLine; i++) {
lType = CheckChTypeNew(i);
switch (lType) {
case CHTYPE_USER:
strText = STR_TOTALLINE_TYPE_USER;
break;
case CHTYPE_TRUNK:
strText = STR_TOTALLINE_TYPE_TRUNK;
break;
case CHTYPE_EMPTY:
strText = STR_TOTALLINE_TYPE_EMPTY;
break;
case CHTYPE_RECORD:
strText = STR_TOTALLINE_TYPE_RECORD;
break;
}
/*我注释一种的任何一句emit 程序做一次循环就出现内存的非法访问*/
/*如果不注释 程序可以做3次循环*/
/*debug 发现是QString一起的错误*/
emit
outTableItem(i, INT_TOTALLINE_ITEM_NUM, QString::number(i));
emit
outTableItem(i, INT_TOTALLINE_ITEM_TYPE, strText);
msleep(500);
}
/////////////////////////////////////////////////////////////////
//slot 定义
public slots:
void startServer(bool checked);
/////////////////////////////////////////////////////////////////
//connect
connect(&classVoiceSystem, SIGNAL(outTableItem(int, int, QString)), this,
SLOT(setTableItem(int, int, QString)));
/////////////////////////////////////////////////////////////////
//slot 我屏蔽主体语句错误依然 可以排除slot中的问题
void CallCenterServer::setTableItem(int nRow, int nCol, QString label) {
QTableWidgetItem *item = new QTableWidgetItem(label);
ui.tableWidget->setItem(nRow, nCol, item);
}