Results 1 to 6 of 6

Thread: Issue by Signal to Slot via proxy

  1. #1
    Join Date
    Aug 2015
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Issue by Signal to Slot via proxy

    Hi there,

    after I get yesterday great help from here (see: http://www.qtcentre.org/threads/6346...lass-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:
    Qt Code:
    1. emit CallKonfig0SetName();
    To copy to clipboard, switch view to plain text mode 

    connection in B:
    Qt Code:
    1. connect(konfig, SIGNAL(CallKonfig0SetName()), this, SLOT(FctProxy0SetName()));
    To copy to clipboard, switch view to plain text mode 

    emit in B:
    Qt Code:
    1. void Start::FctProxy0SetName()
    2. {
    3. btn_as1->setText("DEBUG");
    4. emit CallStart0SetName();
    5. }
    To copy to clipboard, switch view to plain text mode 

    connection in A:
    Qt Code:
    1. connect(start, SIGNAL(CallStart0SetName()), this, SLOT(Fct0SetName()));
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Issue by Signal to Slot via proxy

    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...).

  3. #3
    Join Date
    Aug 2015
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Issue by Signal to Slot via proxy

    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:
    Qt Code:
    1. signals:
    2. void CallKonfig0SetName();
    3. void CallKonfig0SetName();
    4. void CallKonfig0SetName();
    5. void CallKonfig0SetName();
    6. void CallKonfig0SetName();
    To copy to clipboard, switch view to plain text mode 

    in C-declaration:
    Qt Code:
    1. emit CallKonfig0SetName();
    To copy to clipboard, switch view to plain text mode 

    in B-definition:
    Qt Code:
    1. public slots:
    2. void FctProxy0SetName();
    To copy to clipboard, switch view to plain text mode 

    in B-declaration:
    Qt Code:
    1. connect(konfig, SIGNAL(CallKonfig0SetName()), this, SLOT(FctProxy0SetName()));
    To copy to clipboard, switch view to plain text mode 

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

    thanks
    -casisto

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Issue by Signal to Slot via proxy

    When you do the connect in B, does "konfig" already exist?
    Is it always the same instance?

    Cheers,
    _

  5. #5
    Join Date
    Aug 2015
    Location
    Gdansk, Poland
    Posts
    21
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Issue by Signal to Slot via proxy

    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

  6. #6
    Join Date
    Aug 2015
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default <Solved> Re: Issue by Signal to Slot via proxy

    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.

Similar Threads

  1. Replies: 6
    Last Post: 4th March 2014, 15:09
  2. signal/slot issue
    By dpn in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2013, 12:31
  3. a signal-slot issue
    By ceraolo in forum Newbie
    Replies: 2
    Last Post: 28th April 2012, 18:30
  4. Signal / Slot issue
    By sicker in forum Qt Programming
    Replies: 2
    Last Post: 29th July 2011, 21:53
  5. Signal and Slot Issue
    By dlrlsqa1 in forum Newbie
    Replies: 5
    Last Post: 23rd March 2009, 12:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.