Results 1 to 4 of 4

Thread: connect returning false

  1. #1
    Join Date
    Mar 2009
    Posts
    39
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default connect returning false

    I am a very beginner learing by trial and error (well I have read a bit already). I was seeing the most simple example, dirview and I though I'd add some code, an object that would be signaled by the TreeView.

    So I created a class derived from QObject with the Q_OBJECT macro and set a connection (code below) but the return value of connect is always false.

    What I am missing?
    And is there a way to get extended information of the error?

    Qt Code:
    1. Receiver recv;
    2. bool ok=QObject::connect(&tree,SIGNAL(activated(const QModelIndex &)),&recv,SLOT(selected(const ModelIndex &)));
    To copy to clipboard, switch view to plain text mode 

    this is the declaration of Receiver class:

    Qt Code:
    1. class Receiver:public QObject{
    2. Q_OBJECT;
    3.  
    4.  
    5. public slots:
    6. void selected(QModelIndex &);
    7.  
    8. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: connect returning false

    Quote Originally Posted by thru View Post
    And is there a way to get extended information of the error?
    yes, there is a way, just take a look at console (output) and find something like "QObject::connect: ...".
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Mar 2009
    Posts
    39
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: connect returning false

    Thank you spirit! The error was no "such slot" so I reviewed and realized that I was not consistent with the const attribute of the QModelIndex parameter.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: connect returning false

    To me it seems you forgot "Q" in the signature of the slot.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Application only 'animates' once
    By arkain in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2009, 08:09
  2. Problem with connect()
    By mrnor3 in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 14:05
  3. enabling a QTreeWidgetItem as false
    By Kapil in forum Newbie
    Replies: 2
    Last Post: 3rd March 2006, 07:32
  4. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 18:06
  5. connect returns false
    By krivenok in forum Qt Programming
    Replies: 6
    Last Post: 21st February 2006, 20:01

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.