Custum signal in QDialog does not launch a slot in another class
-
check the return value of the connect statement
check the output on the console
this gives you a pretty clear reason whats going wrong.
-
Thank you raven-worx, I have checked if the connect statement works and it does (the bool is 1) and I ve printed something in the saveTableValue slot and it works also....
-
when the connect() returns true the connection is fine and everything will work.
So there must be something else... the posted code looks good. -
exactely I cant find out what's wrong. I tried to emit the same signal in B class and connected in the A class, and it works! the only difference I see is that the case that doesn't work is a QDialog!! what's wrong with that?!
-
should also work. even if you call QDialog::exec() to show it.
Did you try a full rebuild of your project? -
What do you mean with "even if you call QDialog::exec() to show it."?
yes I tried twice to rebuild...nothing
-
[quote author="valeSimu" date="1422369443"]What do you mean with "even if you call QDialog::exec() to show it."?[/quote]
because QDialog::exec() opens a new event-loop. Nevermind.
I don't have any more hints for you sry.
-
Could you show where do you show or exec profDialog.
Is profHullDialog related to profDialog? -
Another question.
How many times do you call Geometry_UI::update()?
In current implementation you create new table on each update. -
- in class B.cpp show the profDialog in thi way
@connect(profBtn, SIGNAL(clicked()), profDialog, SLOT(show()));@
-
and yes proHullDialog and profDialog are the same, I corrected it, thx
-
yes the table is created for every element it finds in a list, for this reason update is called many times
-
The connect in MainWindow ctor uses a Geomentry_UI::profDialog pointer allocated in Geometry_UI ctor.
In Geometry_UI::update() you lose that pointer and allocate another and you use that new pointer to connect with a table widget.
You need to rethink the connections and allocations.@
Main_newUI::Main_newUI(QString pathPj, QWidget *parent)
: QMainWindow(parent)
{
geometryDocks = new Geometry_UI(...); // Creates a pointer to profDialog
profileDialog = geometryDocks->profDialog;
connect(profileDialog, SIGNAL(load()), this, SLOT(reloadIfGeometryChanged())); // Uses that pointer to make a connection.
}void Geometry_UI::update()
{
QTableWidget* profileTable = new QTableWidget(profDialog);
profDialog = new ShapeDialog(profBtn, profileTable); // The pointer previously allocated in ctor is lost here.
connect(profileTable, SIGNAL(cellChanged(int,int)), profDialog, SLOT(saveTableValue(int,int))); // profileTable is connected to new profDialog that is not connected with MainWindow.
}@