Hi,
I am getting a crash while trying to get text() from QLineEdit. I am setting a text on lineEdit in connected slot. However when I tried to get back that text I am getting crash.
I am using Qt3 setText() method of QlineEdit to set the text to the lineEdit.
Here's the code snippet:
I created two classes Class CMain1 and Class CTestApp
class CMain1
{
Q_OBJECT:
----
public:
QString SaveFileName
( ) { return strFileTest or m_pLineEdit
->text
() ;
}
public slots:
void ChooseFile();
private:
};
//I m connecting a push button clicked signal to ChooseFile slot :-
connect(m_pPushButton, SIGNAL(clicked()), SLOT(ChooseFile());
void CMain1::ChosseFile()
{
strFileTest = "SomeValue";
m_pLineEdit->setText(strFileTest);
//Applications behaves as expected here ..sets the desired text to the line edit.
}
Class CTestApp
{
Q_OBJECT:
public:
void GetAppName( ) ;
}
void CTestApp::GetAppName()
{
CMain1 pMain;
QString str
= pMain.
SaveFileName();
// The problem is application crashed at SaveFileName() call.
}
class CMain1
{
Q_OBJECT:
----
public:
QString SaveFileName( ) { return strFileTest or m_pLineEdit->text() ;}
public slots:
void ChooseFile();
private:
QPushButton * m_pPushButton;
QLineEdit * m_pLineEdit;
QString strFileTest;
};
//I m connecting a push button clicked signal to ChooseFile slot :-
connect(m_pPushButton, SIGNAL(clicked()), SLOT(ChooseFile());
void CMain1::ChosseFile()
{
strFileTest = "SomeValue";
m_pLineEdit->setText(strFileTest);
//Applications behaves as expected here ..sets the desired text to the line edit.
}
Class CTestApp
{
Q_OBJECT:
public:
void GetAppName( ) ;
}
void CTestApp::GetAppName()
{
CMain1 pMain;
QString str = pMain.SaveFileName();
// The problem is application crashed at SaveFileName() call.
}
To copy to clipboard, switch view to plain text mode
Bookmarks