Results 1 to 3 of 3

Thread: Connecting to a slot not within an Obejct

  1. #1
    Join Date
    Nov 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Connecting to a slot not within an Obejct

    Hello

    I have a MainWindow with slots and signals and QThread. I have no problem connecting signals from my thread (Control_C) with slots from my mainWindow.

    Qt Code:
    1. connect(this, SIGNAL(connected()), myMainWindow_p, SLOT(establishedConnection()));
    2. connect(this, SIGNAL(disconnected()), myMainWindow_p, SLOT(closedConnection()));
    To copy to clipboard, switch view to plain text mode 

    But the other way around won't work:

    Qt Code:
    1. connect(actionVia_CAN_Bus, SIGNAL(triggered()), myControl_p, SLOT(establishConnectionCan()));
    2. connect(actionVia_RS_232, SIGNAL(triggered()), myControl_p, SLOT(establishConnectionRs232()));
    3. connect(actionDisconnect, SIGNAL(triggered()), myControl_p, SLOT(closeConnection()));
    To copy to clipboard, switch view to plain text mode 

    I get:error C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)'

    Converting from object to Control_C impossible. That makes sense, obviously. But is there a workaround?

    Thanks in advance.

    edit: solved i had to use a cast operator (QObject *)myControl_p
    Last edited by Matze-o; 10th November 2008 at 12:08.

  2. #2
    Join Date
    Oct 2008
    Posts
    70
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Default Re: Connecting to a slot not within an Obejct

    Make sure, that you added include file with Control_C declaration.

  3. #3
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Connecting to a slot not within an Obejct

    Did you use QThread for your thread object? did you add Q_OBJECT?

Similar Threads

  1. How to declare SLOT as a parameter to member function?
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2018, 00:41
  2. Problem When Creating my own Slot
    By Fatla in forum Qt Programming
    Replies: 12
    Last Post: 6th June 2008, 14:44
  3. Replies: 2
    Last Post: 24th March 2008, 16:59
  4. Replies: 1
    Last Post: 1st November 2007, 14:09

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.