View Full Version : Issue by Signal to Slot via proxy

23rd August 2015, 15:26
Hi there,

after I get yesterday great help from here (see: http://www.qtcentre.org/threads/63462-lt-Solved-gt-Pointer-to-Calling-class-is-needed). I've applied my new knowledge. First. it was all Ok. My MainWindow send and receive Signals from his childs.

but I have follow constellation:

A (MainWindow) has a StackedWidget B (Start) which calls a modal QDialog C (konfig). I need to deliver a Signal from C to A. A knows B, and B knows C, so I thought it would be the best if I connect the Signal from C to B and call a function which emit a Signal which is connected in A to a A-function.

But, B should get the Signal but don't jump in the function. I hope anybody can help. Here are some of my Code:

emit in C:

emit CallKonfig0SetName();

connection in B:

connect(konfig, SIGNAL(CallKonfig0SetName()), this, SLOT(FctProxy0SetName()));

emit in B:

void Start::FctProxy0SetName()
emit CallStart0SetName();

connection in A:

connect(start, SIGNAL(CallStart0SetName()), this, SLOT(Fct0SetName()));

I got no error or warning. And in this way it does the trick in my other function. So, is there something I haven't followed?


23rd August 2015, 18:30
I hope anybody can help. Here are some of my Code
It could be useful to have all of your code (or at least the relevant parts), because now we can't know if you have the right declarations in header files (Q_OBJECT macros, slots declared with "slots" keyword etc...).

23rd August 2015, 20:29
Ok, I've tested, the issue is between B and C. If I set the "origin" emit to B, A jump in the responding function. I've trying a clean, run qmake and build too...

So, I don't want to post the hole 1100 lines here, I try to apply Occam's razor. The Q_Object Macro is in both Class definition set. The function which emit the Signal is called.

In C-definition:

void CallKonfig0SetName();
void CallKonfig0SetName();
void CallKonfig0SetName();
void CallKonfig0SetName();
void CallKonfig0SetName();

in C-declaration:

emit CallKonfig0SetName();

in B-definition:

public slots:
void FctProxy0SetName();

in B-declaration:

connect(konfig, SIGNAL(CallKonfig0SetName()), this, SLOT(FctProxy0SetName()));

If you say you need more Code, I will short my Code to a minimum where the failure is still in.


23rd August 2015, 22:13
When you do the connect in B, does "konfig" already exist?
Is it always the same instance?


24th August 2015, 17:41
Hi Casisto,
I think two other guys above get same issue as me, since we can't get the "relevant parts" of your problem, so we just can guess

1. as anda_skoa said, when/where you place the connect function must be valid. In some case it can be too late to "connect" when your dialog already called.
2. make sure the "this" of the receiver refer to the right object & you can use qDebug()<<sender(); inside the slot function to get exact information about the signal sender

24th August 2015, 19:03

failure was found at minimizing... I had declare C in B, but call the show() by "parent", which is A. So, when I call it by "this" it is all right!

very much thanks here.