Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem adding another constructor to QSslCertificate
Forum Updated to NodeBB v4.3 + New Features

Problem adding another constructor to QSslCertificate

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 651 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mythiclese
    wrote on last edited by
    #1

    I added another constructor like this:

        QSslCertificate(); // My new constructor
        explicit QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
        explicit QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem);
        QSslCertificate(const QSslCertificate &other);
    ...
    Q_DECLARE_METATYPE(QSslCertificate)
    

    Here's the initialization:

    QSslCertificate::QSslCertificate()
        : d(new QSslCertificatePrivate)
    {
        QSslSocketPrivate::ensureInitialized();
        d->x509 = X509_new();
    }
    

    Problem is when I go to compile this code i get the following error message:

    QtOpenGL: created fwd-include header(s) for <srcbase>/src/opengl/ { qgl.h (5), qgl_p.h (1), qglbuffer.h (2), qglcolormap.h (2), qglframebufferobject.h (3), qglframebufferobject_p.h (1), qglfunctions.h (3), qglpaintdevice_p.h (1), qglpixelbuffer.h (2), qglpixelbuffer_p.h (1), qglshaderprogram.h (3), qgraphicsshadereffect_p.h (1), qtopenglglobal.h (1) }
    In file included from ../../include/QtCore/qmetatype.h:1:0,
                     from ../../include/QtCore/../../../../../mnt/disk-2/builds/qt5/qtbase/src/corelib/kernel/qobject.h:54,
                     from ../../include/QtCore/qobject.h:1,
                     from ../../include/QtCore/../../../../../mnt/disk-2/builds/qt5/qtbase/src/corelib/kernel/qcoreapplication.h:46,
                     from ../../include/QtCore/qcoreapplication.h:1,
                     from /mnt/disk-2/builds/qt5/qtbase/src/corelib/global/qt_pch.h:62:
    ../../include/QtCore/../../../../../mnt/disk-2/builds/qt5/qtbase/src/corelib/kernel/qmetatype.h: In instantiation of ‘static void* QtMetaTypePrivate::QMetaTypeFunctionHelper<T, Accepted>::Construct(void*, const void*) [with T = QSslCertificate; bool Accepted = true]’:
    ../../include/QtCore/../../../../../mnt/disk-2/builds/qt5/qtbase/src/corelib/kernel/qmetatype.h:1682:53:   required from ‘int qRegisterNormalizedMetaType(const QByteArray&, T*, typename QtPrivate::MetaTypeDefinedHelper<T, (QMetaTypeId2<T>::Defined && (! QMetaTypeId2<T>::IsBuiltIn))>::DefinedType) [with T = QSslCertificate; typename QtPrivate::MetaTypeDefinedHelper<T, (QMetaTypeId2<T>::Defined && (! QMetaTypeId2<T>::IsBuiltIn))>::DefinedType = QtPrivate::MetaTypeDefinedHelper<QSslCertificate, true>::DefinedType]’
    ../../include/QtCore/../../../../../mnt/disk-2/builds/qt5/qtbase/src/corelib/kernel/qmetatype.h:1712:42:   required from ‘int qRegisterMetaType(const char*, T*, typename QtPrivate::MetaTypeDefinedHelper<T, (QMetaTypeId2<T>::Defined && (! QMetaTypeId2<T>::IsBuiltIn))>::DefinedType) [with T = QSslCertificate; typename QtPrivate::MetaTypeDefinedHelper<T, (QMetaTypeId2<T>::Defined && (! QMetaTypeId2<T>::IsBuiltIn))>::DefinedType = QtPrivate::MetaTypeDefinedHelper<QSslCertificate, true>::DefinedType]’
    ../../include/QtNetwork/../../../../../mnt/disk-2/builds/qt5/qtbase/src/network/ssl/qsslcertificate.h:208:1:   required from here
    ../../include/QtCore/../../../../../mnt/disk-2/builds/qt5/qtbase/src/corelib/kernel/qmetatype.h:766:16: error: call of overloaded ‘QSslCertificate()’ is ambiguous
             return new (where) T;
                    ^~~~~~~~~~~~~
    cd themes/ && ( test -e Makefile || /tmp/makepkg/qt5-base-server-side-sni/bin/qmake -o Makefile /mnt/disk-2/builds/qt5/qtbase/src/platformsupport/themes/themes.pro ) && make -f Makefile 
    In file included from ../../include/QtNetwork/qsslcertificate.h:1:0,
                     from ../../include/QtNetwork/../../../../../mnt/disk-2/builds/qt5/qtbase/src/network/ssl/qsslerror.h:46,
                     from ../../include/QtNetwork/qsslerror.h:1,
                     from ../../include/QtNetwork/../../../../../mnt/disk-2/builds/qt5/qtbase/src/network/ssl/qsslsocket.h:49,
                     from ../../include/QtNetwork/qsslsocket.h:1,
                     from ../../include/QtNetwork/../../../../../mnt/disk-2/builds/qt5/qtbase/src/network/ssl/qsslconfiguration.h:61,
                     from ../../include/QtNetwork/qsslconfiguration.h:1,
                     from ../../include/QtNetwork/QSslConfiguration:1,
                     from /mnt/disk-2/builds/qt5/qtbase/src/network/access/qnetworkaccessmanager.h:46,
                     from /mnt/disk-2/builds/qt5/qtbase/src/network/access/qnetworkaccessmanager_p.h:55,
                     from /mnt/disk-2/builds/qt5/qtbase/src/network/access/qnetworkaccesscache.cpp:44:
    ../../include/QtNetwork/../../../../../mnt/disk-2/builds/qt5/qtbase/src/network/ssl/qsslcertificate.h:91:5: note: candidate: QSslCertificate::QSslCertificate(const QByteArray&, QSsl::EncodingFormat)
         QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem);
         ^~~~~~~~~~~~~~~
    ../../include/QtNetwork/../../../../../mnt/disk-2/builds/qt5/qtbase/src/network/ssl/qsslcertificate.h:89:5: note: candidate: QSslCertificate::QSslCertificate()
         QSslCertificate();
         ^~~~~~~~~~~~~~~
    

    It's erroring on the macro Q_DECLARE_METATYPE, and I can't figure out why. QFileInfo and QDBusUnixFileDescriptor are examples that are doing the same thing without any problems.

    QFileInfo:

        QFileInfo();
        QFileInfo(const QString &file);
        QFileInfo(const QFile &file);
        QFileInfo(const QDir &dir, const QString &file);
        QFileInfo(const QFileInfo &fileinfo);
        ~QFileInfo();
    ...
    Q_DECLARE_METATYPE(QFileInfo)
    

    QDBusUnixFileDescriptor:

        QDBusUnixFileDescriptor();
        explicit QDBusUnixFileDescriptor(int fileDescriptor);
        QDBusUnixFileDescriptor(const QDBusUnixFileDescriptor &other);
    #if defined(Q_COMPILER_RVALUE_REFS)
        QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other) Q_DECL_NOTHROW { swap(other); return *this; }
    #endif
        QDBusUnixFileDescriptor &operator=(const QDBusUnixFileDescriptor &other);
        ~QDBusUnixFileDescriptor();
    ...
    Q_DECLARE_METATYPE(QDBusUnixFileDescriptor)
    

    I'm trying to create a null certificate so I can then populate it with information dynamically with the purpose of giving QtSsl the ability to create Ssl certificates. This is driving me nuts. Any help would be greatly appreciated.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      You have 2 constructors that do the same thing.

      You have a default with QSslCertificate() then you have an overloaded one with QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem).

      So it's telling you the constructor call is ambiguous as it doesn't know how to differentiate between those 2. Add a non-defaulted parameter to your constructor or (and this isn't a good idea) remove the QByteArray() default from Qt's constructor.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mythiclese
        wrote on last edited by
        #3

        Thank you very much for the answer. I didn't even notice that QByteArray &data had a default value, and didn't take that into account! You saved me from tearing my hair out.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved