Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error popping up message box after modifying table column
Qt 6.12 LTS is out! See what's new in the release blog

Error popping up message box after modifying table column

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 3 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I IknowQT
    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.

    c29dc0b9-d55f-4449-8c3f-540e1df26908-image.png

    예외 발생(0x00007FF9B4FA63BC(Qt5Cored.dll), MainWidget.exe): 0xC0000005: 0xFFFFFFFFFFFFFFFF 위치를 읽는 동안 액세스 위반이 발생했습니다..

    << call stack info

    223d1919-110a-432b-bdf1-0dbe94dd993a-image.png

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @IknowQT Please translate the error message!
    Why const_cast?! Why don't you change the signal/slot signature instead to remove const?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    I 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #3

      The message box spins a new eventloop and therefore the lineEdit is already gone or similar conditions.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      I 1 Reply Last reply
      0
      • jsulmJ jsulm

        @IknowQT Please translate the error message!
        Why const_cast?! Why don't you change the signal/slot signature instead to remove const?

        I Offline
        I Offline
        IknowQT
        wrote on last edited by
        #4

        @jsulm

        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

        jsulmJ 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          The message box spins a new eventloop and therefore the lineEdit is already gone or similar conditions.

          I Offline
          I Offline
          IknowQT
          wrote on last edited by
          #5

          @Christian-Ehrlicher

          	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.

          1 Reply Last reply
          0
          • I IknowQT

            @jsulm

            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

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            I 1 Reply Last reply
            0
            • jsulmJ jsulm

              @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.

              I Offline
              I Offline
              IknowQT
              wrote on last edited by
              #7

              @jsulm

              It was my mistake. It has become a habit.
              What steps can I take next? The error is the same.

              jsulmJ 1 Reply Last reply
              0
              • I IknowQT

                @jsulm

                It was my mistake. It has become a habit.
                What steps can I take next? The error is the same.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @IknowQT said in Error popping up message box after modifying table column:

                What steps can I take next?

                1. Post current code
                2. Let us know from which line of your code the error originates from

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                I 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @IknowQT said in Error popping up message box after modifying table column:

                  What steps can I take next?

                  1. Post current code
                  2. Let us know from which line of your code the error originates from
                  I Offline
                  I Offline
                  IknowQT
                  wrote on last edited by
                  #9

                  @jsulm

                  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;
                  }
                  
                  jsulmJ 1 Reply Last reply
                  0
                  • I IknowQT

                    @jsulm

                    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;
                    }
                    
                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @IknowQT Would be nice if you would also answer second question...

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    I 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @IknowQT Would be nice if you would also answer second question...

                      I Offline
                      I Offline
                      IknowQT
                      wrote on last edited by IknowQT
                      #11

                      @jsulm

                      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
                      }
                      
                      jsulmJ 1 Reply Last reply
                      0
                      • I IknowQT

                        @jsulm

                        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
                        }
                        
                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by jsulm
                        #12

                        @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.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        I 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @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.

                          I Offline
                          I Offline
                          IknowQT
                          wrote on last edited by
                          #13

                          @jsulm

                          If you look at my first post, I've captured and posted about the call stack.
                          You may refer to the contents of the capture. This is not the call stack I have access to.

                          jsulmJ 1 Reply Last reply
                          0
                          • I IknowQT

                            @jsulm

                            If you look at my first post, I've captured and posted about the call stack.
                            You may refer to the contents of the capture. This is not the call stack I have access to.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            @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...

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            I 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @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...

                              I Offline
                              I Offline
                              IknowQT
                              wrote on last edited by IknowQT
                              #15

                              @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.

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt
                              • Unsolved