Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] C++ Function Calls



  • I get this error:

    @C:\Users\Darrel\Desktop\smartphonebrainscanner2-Brain3D\qmlapplicationviewer\qmlapplicationviewer.cpp:77: error: no matching function for call to 'QQuickView::QQuickView(QWidget*&)'
    , d(new QmlApplicationViewerPrivate())
    ^@

    From this code:

    @
    QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
    : QQuickView(parent)
    , d(new QmlApplicationViewerPrivate())
    {
    connect(engine(), SIGNAL(quit()), SLOT(close()));
    setResizeMode(QQuickView::SizeRootObjectToView); //(QDeclarativeView::SizeRootObjectToView); Qt 4.8

    // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
    

    #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
    #if !defined(NO_JSDEBUGGER)
    new QmlJSDebugger::JSDebuggerAgent(engine());
    #endif
    #if !defined(NO_QMLOBSERVER)
    new QmlJSDebugger::QDeclarativeViewObserver(this, this);
    #endif
    #endif
    }@

    @class QmlApplicationViewer : public QQuickView //QDeclarativeView // Qt 4.8
    {
    Q_OBJECT

    public:
    enum ScreenOrientation {
    ScreenOrientationLockPortrait,
    ScreenOrientationLockLandscape,
    ScreenOrientationAuto
    };

    explicit QmlApplicationViewer(QWidget *parent = 0);
    virtual ~QmlApplicationViewer();
    
    static QmlApplicationViewer *create();
    
    void setMainQmlFile&#40;const QString &file&#41;;
    void addImportPath(const QString &path&#41;;
    
    // Note that this will only have an effect on Fremantle.
    void setOrientation(ScreenOrientation orientation);
    
    void showExpanded();
    

    private:
    class QmlApplicationViewerPrivate *d;
    };@

    It's been awhile since I've worked on C++ classes so I'm pretty rusty. I don't see the problem.



  • You are calling a constructor while you haven't defined any for the class you mention, I think that might be the reason why it is not working.
    First define a constructor then you can call @new QmlApplicationViewerPrivate()@



  • isn't it already defined in

    @private:
    class QmlApplicationViewerPrivate *d;@

    and then here is this:

    @
    class QmlApplicationViewerPrivate
    {
    QString mainQmlFile;
    friend class QmlApplicationViewer;
    static QString adjustPath(const QString &path);
    };@



  • Well the first thing is that I don't see why you are using the key word "class" here
    @private:
    class QmlApplicationViewerPrivate *d;@
    Indeed, if your class QmlApplicationViewerPrivate is defined in a .h you can simply include it in your QmlApplicationViewer file ;).

    As for this part of the code here :
    @class QmlApplicationViewerPrivate
    {
    QString mainQmlFile;
    friend class QmlApplicationViewer;
    static QString adjustPath(const QString &path);
    };@

    You are indeed defining a class with its attributes and methods, but I don't see any constructor which goes like : QmlApplicationViewer(type1 att1, type2 att2...){
    }



  • perfect, thank you :)



  • You're very welcome ! Please mark the topic as solved and good luck with the rest of your coding ;-)


Log in to reply