Unable to access members of same class, giving seg fault
I am trying to create a slot from object to other
frame to log , but both belongs to same class
when trying to access objects placed on log , they are becoming invalid.
how to solve the problem?
Code:
QWidget* ApplicationLog
::createLogWindow() {
m_pCmdLogHL->addWidget(m_pLogTE);
}
Code:
QWidget* ApplicationLog
::createFrameWindow() {
m_pMinMaxBut = new Button(this,"Minimize");
connect(m_pMinMaxBut,SIGNAL(clicked()),this,SLOT(logWindowMinMax()));
m_bIsMaximize = 1;
}
Code:
void ApplicationLog::logWindowMinMax()
{
qDebug()<<"slot invoked" ;
if(m_bIsMaximize)
{
m_pLogTE->setVisible(false);
m_pMinMaxBut->setTooltip("Maximize");
m_bIsMaximize = 0;
}
else
{
m_pLogTE->setVisible(true);
m_bIsMaximize = 1;
m_pMinMaxBut->setTooltip("Minimize");
}
}
in the main window i am calling
Code:
QWidget* frame
= framewindow
->createFrameWindow
();
QWidget* log = logwindow
->createLogWindow
();
this particular line is giving problem (segmentation)
Code:
m_pLogTE->setVisible(false);
why is it wrong to access that object,how to access the object?
Re: Unable to access members of same class, giving seg fault
No return statements in functions returning non-void:
Code:
QWidget* ApplicationLog
::createLogWindow() {
m_pCmdLogHL->addWidget(m_pLogTE);
// return !
}
QWidget* ApplicationLog
::createFrameWindow() {
m_pMinMaxBut = new Button(this,"Minimize");
connect(m_pMinMaxBut,SIGNAL(clicked()),this,SLOT(logWindowMinMax()));
m_bIsMaximize = 1;
// return !
}
Another thing, check if createLogWindow() is called before trying to access m_pLogTE object.
Re: Unable to access members of same class, giving seg fault
The OP's code won't even compile, much less execute, so obviously we are not seeing the whole story. As amleto says in every post:
Quote:
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.