Results 1 to 7 of 7

Thread: connect returns false

  1. #1
    Join Date
    Jan 2006
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default connect returns false

    connect returns false. How can I retrieve detailed description of occured error?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect returns false

    You could catch all qWarning messages using qInstallMsgHandler() or check the arguments yourself using QMetaObject.

  3. #3
    Join Date
    Jan 2006
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: connect returns false

    I find many problems in my code, after installing qInstallMsgHandler() handler
    But nothing related to connect call

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect returns false

    Quote Originally Posted by krivenok
    I find many problems in my code, after installing qInstallMsgHandler() handler
    All of these warnings are usually written to the console, but on windows you have to add CONFIG += console to your .pro file (or use your own message handler) to see them.

    But nothing related to connect call
    Try compiling your program in debug mode (CONFIG += debug in the .pro file).

  5. #5
    Join Date
    Feb 2006
    Location
    Roma ( Italy )
    Posts
    7
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: connect returns false

    what's your proble?
    do you can post yuor code?

  6. #6
    Join Date
    Jan 2006
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: connect returns false

    The code below is QT's connect implementation.

    bool QObject::connect(const QObject *sender, const char *signal,
    const QObject *receiver, const char *method,
    Qt::ConnectionType type)
    {
    #ifndef QT_NO_DEBUG
    bool warnCompat = true;
    #endif
    if (type == Qt::AutoCompatConnection) {
    type = Qt::AutoConnection;
    #ifndef QT_NO_DEBUG
    warnCompat = false;
    #endif
    }

    if (sender == 0 || receiver == 0 || signal == 0 || method == 0) {
    #ifndef QT_NO_DEBUG
    qWarning("Object::connect: Cannot connect %s::%s to %s::%s",
    sender ? sender->metaObject()->className() : "(null)",
    signal ? signal+1 : "(null)",
    receiver ? receiver->metaObject()->className() : "(null)",
    method ? method+1 : "(null)");
    #endif
    return false;
    }
    QByteArray tmp_signal_name;

    #ifndef QT_NO_DEBUG
    if (!check_signal_macro(sender, signal, "connect", "bind"))
    return false;
    #endif
    const QMetaObject *smeta = sender->metaObject();
    ++signal; //skip code
    int signal_index = smeta->indexOfSignal(signal);
    if (signal_index < 0) {
    // check for normalized signatures
    tmp_signal_name = QMetaObject::normalizedSignature(signal).prepend(* (signal - 1));
    signal = tmp_signal_name.constData() + 1;
    signal_index = smeta->indexOfSignal(signal);
    if (signal_index < 0) {
    #ifndef QT_NO_DEBUG
    err_method_notfound(QSIGNAL_CODE, sender, signal, "connect");
    err_info_about_objects("connect", sender, receiver);
    #endif
    return false;
    }
    }

    QByteArray tmp_method_name;
    int membcode = method[0] - '0';

    #ifndef QT_NO_DEBUG
    if (!check_method_code(membcode, receiver, method, "connect"))
    return false;
    #endif
    ++method; // skip code

    const QMetaObject *rmeta = receiver->metaObject();
    int method_index = -1;
    switch (membcode) {
    case QSLOT_CODE:
    method_index = rmeta->indexOfSlot(method);
    break;
    case QSIGNAL_CODE:
    method_index = rmeta->indexOfSignal(method);
    break;
    }
    if (method_index < 0) {
    // check for normalized methods
    tmp_method_name = QMetaObject::normalizedSignature(method);
    method = tmp_method_name.constData();
    switch (membcode) {
    case QSLOT_CODE:
    method_index = rmeta->indexOfSlot(method);
    break;
    case QSIGNAL_CODE:
    method_index = rmeta->indexOfSignal(method);
    break;
    }
    }

    if (method_index < 0) {
    #ifndef QT_NO_DEBUG
    err_method_notfound(membcode, receiver, method, "connect");
    err_info_about_objects("connect", sender, receiver);
    #endif
    return false;
    }
    #ifndef QT_NO_DEBUG
    if (!QMetaObject::checkConnectArgs(signal, method)) {
    qWarning("Object::connect: Incompatible sender/receiver arguments"
    "\n\t%s::%s --> %s::%s",
    sender->metaObject()->className(), signal,
    receiver->metaObject()->className(), method);
    return false;
    }
    #endif

    int *types = 0;
    if (type == Qt::QueuedConnection
    && !(types = ::queuedConnectionTypes(smeta->method(signal_index).parameterTypes())))
    return false;

    #ifndef QT_NO_DEBUG
    {
    QMetaMethod smethod = smeta->method(signal_index);
    QMetaMethod rmethod = rmeta->method(method_index);
    if (warnCompat) {
    if(smethod.attributes() & QMetaMethod::Compatibility) {
    if (!(rmethod.attributes() & QMetaMethod::Compatibility))
    qWarning("Object::connect: Connecting from COMPAT signal (%s::%s).", smeta->className(), signal);
    } else if(rmethod.attributes() & QMetaMethod::Compatibility && membcode != QSIGNAL_CODE) {
    qWarning("Object::connect: Connecting from %s::%s to COMPAT slot (%s::%s).",
    smeta->className(), signal, rmeta->className(), method);
    }
    }
    }
    #endif
    QMetaObject::connect(sender, signal_index, receiver, method_index, type, types);
    const_cast<QObject*>(sender)->connectNotify(signal - 1);
    return true;
    }

  7. #7
    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 returns false

    I think preposter meant your code and not Qt code

Similar Threads

  1. Strange error: doc.setContent(data) returns false
    By jiveaxe in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2009, 01:38
  2. QSslSocke::supportSsl() returns false
    By oscar in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2008, 18:51
  3. QSqlQuery::isValid returns false
    By mismael85 in forum Qt Programming
    Replies: 24
    Last Post: 7th September 2008, 23:43
  4. Problem with connect()
    By mrnor3 in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 14:05
  5. connect() returns true but slot not called
    By OriginalCopy in forum Qt Programming
    Replies: 6
    Last Post: 4th November 2007, 18:54

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.