Results 1 to 3 of 3

Thread: How to connect signal to signal in QWidget correctly

  1. #1
    Join Date
    Nov 2011
    Posts
    14
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4 Qt Jambi
    Platforms
    MacOS X Windows

    Default How to connect signal to signal in QWidget correctly

    Hi everyone!

    I am having trouble with conneting two signals.
    I have WindowsMenu and there is PlotBackgroundMenuinside.
    BackgroundColorChanged(CPlotBackgroundMenu::Backgr oundColor color) signal is emited in PlotColorMenu (Color is enum) when one of the menu's actions is trigged.

    I did following in WindowMenu:
    Qt Code:
    1. void CWindowsMenu::makeConnections()
    2. {
    3. connect(PlotBackgroundMenu,SIGNAL(BackgroundColorChanged(CPlotBackgroundMenu::BackgroundColor)),
    4. this,SIGNAL(BackColorChanged(CPlotBackgroundMenu::BackgroundColor)));
    5. }
    To copy to clipboard, switch view to plain text mode 

    and I called makeConnections() in WindowMenu constractor.


    Then I used the signal BackColorChanged in MainWindow to connect it with the slot to actually change the color.

    It didn't work.

    What am I missing?

    P.S. I read QWidget references and searched for examples, still don't get it

    Thank you!

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to connect signal to signal in QWidget correctly

    Check for any error in Application output
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to connect signal to signal in QWidget correctly

    It didn't work.
    What didn't work?

    The MainWindow slot didn't get invoked?

    The background color didn't change?

    The WindowMenu signal wasn't emitted in the first place?

    You've shown us 5 lines of code out of what is obviously a multi-step signal / slot handling sequence. Why do you assume that something is wrong with the connect statement? The error could be anywhere in the code you aren't showing us.

    Post a minimal example that demonstrates the problem, and we might be able to help you find what is wrong.

Similar Threads

  1. How to connect a slot(QWidget*) with signal(clicked())
    By revellix in forum Qt Programming
    Replies: 10
    Last Post: 5th August 2011, 16:19
  2. Connect signal/signal in Qt Designer
    By jlemaitre in forum Newbie
    Replies: 1
    Last Post: 22nd September 2010, 15:53
  3. Can't connect a signal to a slot
    By cejohnsonsr in forum Newbie
    Replies: 5
    Last Post: 26th August 2010, 20:42
  4. QObject::connect: No such signal
    By caseyong in forum Qt Programming
    Replies: 5
    Last Post: 19th February 2008, 07:23
  5. can i connect a signal to a signal
    By amit_pansuria in forum Qt Programming
    Replies: 1
    Last Post: 29th August 2007, 06:28

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.