Error popping up message box after modifying table column
-
usrTableDelegate* pFrozen = static_cast<usrTableDelegate*>(this->ui.tableWidget->GetFrozenTable()->itemDelegate()); this->connect(pFrozen, &usrTableDelegate::UserDefine_EnableEditable, [=](const usrSetupLineEdit* editor) { usrSetupLineEdit* lineEdit = const_cast<usrSetupLineEdit*>(editor); connect(lineEdit, &usrSetupLineEdit::UserDefineReturnPress, [this, lineEdit]() { bool bRet = cGlobalParam::FloatingPointComparison(lineEdit->text().toDouble(), m_strPrevConc.toDouble()); if (ConcContain(lineEdit->text())) { QMessageBox msg; msg.setText("asdasdasD"); msg.exec(); } }); });
usrTableDelegate is a class that inherits styleDelegate. When editing a table column by double-clicking it, I created an Edittable with usrSetupLineEdit. An attempt was made to display a message by checking for duplicates of the entered characters. The message works normally, but after clicking the OK button on the message pop-up window, the program dies.
예외 발생(0x00007FF9B4FA63BC(Qt5Cored.dll), MainWidget.exe): 0xC0000005: 0xFFFFFFFFFFFFFFFF 위치를 읽는 동안 액세스 위반이 발생했습니다..
<< call stack info
-
The message box spins a new eventloop and therefore the lineEdit is already gone or similar conditions.
-
Exception thrown (0x00007FF9B4FA63BC (Qt5Cored.dll), MainWidget.exe): 0xC0000005: 0xFFFFFFFFFFFFFFFFFF Access violation while reading location.
How to remove const and change signature of signal slot?
This method I did is an example I found by Googling.If I remove the const and use static_cast it throws an error.
C2338 Signal and slot arguments are not compatible. MainWidget C:\Qt\5.15.2\msvc2019_64\include\QtCore\qobject.h 328
C2955 'QtPrivate::AreArgumentsCompatible': use of class template requires template argument list. MainWidget C:\Qt\5.15.2\msvc2019_64\include\QtCore\qobject.h 333 -
usrTableDelegate* pFrozen = static_cast<usrTableDelegate*>(this->ui.tableWidget->GetFrozenTable()->itemDelegate()); this->connect(pFrozen, &usrTableDelegate::UserDefine_EnableEditable, [=](usrSetupLineEdit* editor) { usrSetupLineEdit* lineEdit = static_cast<usrSetupLineEdit*>(editor); this->connect(lineEdit, &usrSetupLineEdit::UserDefineReturnPress, [=]() { bool bRet = cGlobalParam::FloatingPointComparison(lineEdit->text().toDouble(), m_strPrevConc.toDouble()); if (ConcContain(lineEdit->text())) { } }); QMessageBox msg; msg.setText("asdasdasD"); msg.exec(); });
I changed the location of Qmessagebox and ran it, and it works fine.
-
@IknowQT said in Error popping up message box after modifying table column:
How to remove const and change signature of signal slot?
Come on: you know how to edit source code/text?
Why do you cast usrSetupLineEdit* to usrSetupLineEdit* ?! editor IS already a usrSetupLineEdit*! Please think about what you are doing. -
@IknowQT said in Error popping up message box after modifying table column:
What steps can I take next?
- Post current code
- Let us know from which line of your code the error originates from
-
usrTableDelegate* pFrozen = static_cast<usrTableDelegate*>(this->ui.tableWidget->GetFrozenTable()->itemDelegate()); this->connect(pFrozen, &usrTableDelegate::UserDefine_EnableEditable, [=](const usrSetupLineEdit* editor) { //usrSetupLineEdit* lineEdit = static_cast<usrSetupLineEdit*>(editor); this->connect(editor, &usrSetupLineEdit::UserDefineReturnPress, [=]() { if (ConcContain(editor->text())) { QMessageBox msg; msg.setText("asdasdasD"); msg.exec(); //Show(); int a = 0; int b = 0; //emit UserDefine_Msg(); } }); /*QMessageBox msg; msg.setText("asdasdasD"); msg.exec();*/ }); QWidget* usrTableDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { usrSetupLineEdit* pEdit = new usrSetupLineEdit(parent);//qobject_cast<usrSetupLineEdit*>(lineEdit); pEdit->SetOnlyNumber(true, true); pEdit->SetRange(m_min, m_max); pEdit->setAlignment(Qt::AlignCenter); emit UserDefine_EnableEditable(pEdit); return pEdit; }
-
sorry.
If you click OK in the message box after executing msg.exec(), it occurs in return a.exec() of the main widget class.
The program terminates immediately without any intermediate process, and the call stack cannot be looked up.int main(int argc, char* argv[]) { MainWidget* wMain = new MainWidget(); ShowMainWidget(wMain); return a.exec(); /// an error occurs here }
-
@IknowQT said in Error popping up message box after modifying table column:
and the call stack cannot be looked up
I don't believe that. Run your app built in debug mode until it crashes, then you will have the stack trace.
-
@IknowQT said in Error popping up message box after modifying table column:
If you look at my first post, I've captured and posted about the call stack
You also changed the code in the meantime...
-
@jsulm said in Error popping up message box after modifying table column:
You also changed the code in the meantime...
Even if the code is changed, the contents are similar and the contents of the error are the same. That doesn't seem to be the issue.