I mean C++ type... To make you things easier I can say that in this code:
{
if(item=="PLC")
{
PLCconfig=new plcconfiguration();
main_tab_widget->insertTab(0,PLCconfig, "PLC");
main_tab_widget->setCurrentIndex(0);
PLCconfig->show();
}
else if(item==lnx)
{
ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
ECLogic_Lnx
->setWindowTitle
(QString("ECLOGIC-LNX"));
ECLogic_Lnx->show();
}
}
void ECLogic::showItem(QTreeWidgetItem* item )
{
if(item=="PLC")
{
PLCconfig=new plcconfiguration();
main_tab_widget->insertTab(0,PLCconfig, "PLC");
main_tab_widget->setCurrentIndex(0);
PLCconfig->show();
}
else if(item==lnx)
{
ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
ECLogic_Lnx->setWindowTitle(QString("ECLOGIC-LNX"));
ECLogic_Lnx->show();
}
}
To copy to clipboard, switch view to plain text mode
item's type is QTreeWidgetItem* and "PLC" is const char *, so both are pointers. Do you want to compare two memory addresses of two completely different things? I don't think so...
And again:
You have created them in another method as local variables so they not exist where you want to reference them. They are dead :]
Your problem now is pure C++ issue. Please revise your C++ basics, like local variables, scopes, referencing pointers and so on.
And your project your slot showItem looks:
{
ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
ECLogic_Lnx
->setWindowTitle
(QString("ECLOGIC-LNX"));
ECLogic_Lnx->show();
item << "PLC" << "CPU CONFIGURATION" << "PROGRAM VARIABLE CONFIGURATION" << "IO CONFIGURATION"
<< "BIN" << "SLOT" <<"LADDER PROGRAM";
if(item=="PLC")
{
PLCconfig=new plcconfiguration();
main_tab_widget->insertTab(0,PLCconfig, "PLC");
main_tab_widget->setCurrentIndex(0);
PLCconfig->show();
}
else if(item==lnx)
{
ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
ECLogic_Lnx
->setWindowTitle
(QString("ECLOGIC-LNX"));
ECLogic_Lnx->show();
}
}
void ECLogic::showItem(QTreeWidgetItem* item )
{
ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
ECLogic_Lnx->setWindowTitle(QString("ECLOGIC-LNX"));
ECLogic_Lnx->show();
QStringList item;
item << "PLC" << "CPU CONFIGURATION" << "PROGRAM VARIABLE CONFIGURATION" << "IO CONFIGURATION"
<< "BIN" << "SLOT" <<"LADDER PROGRAM";
if(item=="PLC")
{
PLCconfig=new plcconfiguration();
main_tab_widget->insertTab(0,PLCconfig, "PLC");
main_tab_widget->setCurrentIndex(0);
PLCconfig->show();
}
else if(item==lnx)
{
ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
ECLogic_Lnx->setWindowTitle(QString("ECLOGIC-LNX"));
ECLogic_Lnx->show();
}
}
To copy to clipboard, switch view to plain text mode
Which does not make sense at all.
EDIT:
Oops now I found that there is another
lnx variable which is class member - that would be better, but when you are creating new QTreeWidgetItem you are assigning it to the local variable with the same name (lnx) so your member variable lnx is always unassigned and referencing it will cause segmentation fault.
Bookmarks