Solved how to call Mainwindow method from a childwindow.cpp
-
@moyin Are you sure signal is emitted?
-
@jsulm thanks for rply,
i dont how to confirm the signal is emitted or not but when i run the application in debug mode and step into emit after_import(); it takes me into this code snippet. that i already shared you./ SIGNAL 0
void Import::after_import()
{
QMetaObject::activate(this, &staticMetaObject, 0, 0);
}
QT_END_MOC_NAMESPACE -
@moyin You can just put a breakpoint in your slot. Or when you're in that code block then just go further (step) to see what is happening.
Also doqDebug() << connect(imp, SIGNAL(after_import()),this, SLOT(slot_load_cell_dropdownlist()));
to see whether the connection was actually successful.
-
@jsulm , yes! that is
qDebug() << connect(imp, SIGNAL(after_import()),this, SLOT(slot_load_cell_dropdownlist()));
returning true.And if i put BreakPoint in slot_load_cell_dropdownlist(). debugger not reaching to that BreakPoint.
-
@moyin Do you by any chance have more than one Import instance?
And what are you doing in slot_load_cell_dropdownlist()? -
@jsulm
@ Do you by any chance have more than one Import instance?
YES!
Actually i have 2 import instance to the same pointer (imp) .@what are you doing in slot_load_cell_dropdownlist()?
i am just reinitialising a Qcombobox. -
@moyin said in how to call Mainwindow method from a childwindow.cpp:
Actually i have 2 import instance to the same pointer (imp) .
What?! Why? Then the first one is lost as you overwrite the pointer when you create the second instance. And which of them did you actually connected?
-
@jsulm Now i changed my code like,
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ui->setupUi(this); QFont font("Plastique",10);
// font.setStyleHint(QFont::Monospace);
QApplication::setFont(font);
ui->tabWidget_Main->setHidden(true);ui->tabWidget_CELL_CONFIG->setHidden(true); ui->tableWidget_cell_config_2->setColumnWidth(4,250); Disable_Root_Tabs(); Disable_LS_Buttons();
// Import *temp = new Import() ;
// connect(temp, SIGNAL(after_import()),this, SLOT(slot_load_cell_dropdownlist()));
imp2 = new Import(this) ;
std::cout << "just before connect" << std::endl;
qDebug() << connect(imp2, SIGNAL(after_import()),this, SLOT(slot_load_cell_dropdownlist()));
std::cout << "just after connect" << std::endl;
} -
@jsulm
Same result it is not calling slot_load_cell_dropdownlist() at all. -
yeah! man its working thanks alot.