在qt的表格里插入combox,然后在空的表格上,先点击一下,等表格被选中之后,按任意字母,程序就会卡死。正常情况下点击表格选中后,点击数字键会直接将数字写入表格,点击字符按键,会进入表格信息写入的状态,但是按下的字符键不会写入表格中。
部分代码如下:
for (int row = 3; row < ui.tableWidget->rowCount(); ++row) {
QComboBox* comboBox = new QComboBox();//类型
// 添加选项
comboBox->addItem("");
comboBox->addItem("String");
comboBox->addItem("Double");
comboBox->addItem("Int");
// 设置下拉框
ui.tableWidget->setCellWidget(row, 2, comboBox);
}
报错位置:
bool QObject::event(QEvent *e)
{
switch (e->type()) {
case QEvent::Timer:
timerEvent((QTimerEvent*)e);
break;
case QEvent::ChildAdded:
case QEvent::ChildPolished:
case QEvent::ChildRemoved:
childEvent((QChildEvent*)e);
break;
case QEvent::DeferredDelete:
qDeleteInEventHandler(this);
break;
case QEvent::MetaCall:
{
...
```c++
bool QApplication::notify(QObject *receiver, QEvent *e)
{
Q_D(QApplication);
// no events are delivered after ~QCoreApplication() has started
if (QApplicationPrivate::is_app_closing)
return true;
if (Q_UNLIKELY(!receiver)) { // serious error
qWarning("QApplication::notify: Unexpected null receiver");
return true;
}
#ifndef QT_NO_DEBUG
QCoreApplicationPrivate::checkReceiverThread(receiver);
#endif
```c++
QThreadData *QThreadData::current(bool createIfNecessary)
{
qt_create_tls();
QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index));
if (!threadData && createIfNecessary) {
threadData = new QThreadData;
// This needs to be called prior to new AdoptedThread() to
// avoid recursion.
TlsSetValue(qt_current_thread_data_tls_index, threadData);
QT_TRY {
threadData->thread = new QAdoptedThread(threadData);
} QT_CATCH(...) {
TlsSetValue(qt_current_thread_data_tls_index, 0);
threadData->deref();
threadData = 0;
QT_RETHROW;
}
每次报错的位置也不一样,但都是提示未处理的异常。