PDA

View Full Version : Issue by Signal to Slot via proxy



Casisto
23rd August 2015, 16: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()
{
btn_as1->setText("DEBUG");
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?

-casisto

stampede
23rd August 2015, 19: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...).

Casisto
23rd August 2015, 21: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:

signals:
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.

thanks
-casisto

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

Cheers,
_

Frdz
24th August 2015, 18: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

Casisto
24th August 2015, 20:03
Ok,

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.