QML Camera problem



  • Hello,

    I have problems trying to use the QML QtMultimedia Camera but the program just crashes and displays a Messagebox:

    bq. This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.

    The Application Output window displays the message:

    bq. QWidget: Cannot create a QWidget without QApplication
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.
    D:\Qt\Programs\build-untitled5-Desktop_Qt_5_1_0_MinGW_32bit-Release\release\untitled5.exe exited with code 3

    Here's the program:

    @import QtQuick 2.0
    import QtMultimedia 5.0

    Rectangle {
    width: 360
    height: 360
    color: "lightgrey"

    Camera {
        id: bla
    }
    

    }
    @

    I can't seem to find anything on this problem. The webcam works fine. The platform is Win7 x64 and Qt 5.1 with MinGW.


  • Moderators

    First problem are problably some missing dependencies, search for it: I've seen it happen to many people before with MinGW. I don't know the solution myself, I'm mostly on Linux.

    For the second one, please post relevant parts of your code, especially where your main() function is.



  • Dependencies? I didn't think this could happen if the program is run from QtCreator. I know it can happen if I try to run the program outside of QtCreator, but this is not what I'm doing.

    As for the code, I didn't change anything from what Qt generates for a Qt Quick 2 program.


  • Moderators

    Something is clearly wrong. I won't help you by using my magic wand, though. You either need to check it yourself, or post more info...



  • This is a coincidence. I just ran into this one myself. Make sure that in your driver main.cpp the app is a QApplication, NOT a QGuiApplication. Oddly, a QGuiApplication will work in Linux, but not under Win7. I think it probably has to do with what kind of widget gets generated for the underlying camera interface, i.e. DirectShow in Windows.



  • main.cpp

    @#include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile&#40;QStringLiteral("qml/untitled5/main.qml"&#41;);
    viewer.showExpanded();
    
    return app.exec();
    

    }
    @

    .pro

    @# Add more folders to ship with the application, here
    folder_01.source = qml/untitled5
    folder_01.target = qml
    DEPLOYMENTFOLDERS = folder_01

    Additional import path used to resolve QML modules in Creator's code model

    QML_IMPORT_PATH =

    If your application uses the Qt Mobility libraries, uncomment the following

    lines and add the respective components to the MOBILITY variable.

    CONFIG += mobility

    MOBILITY +=

    The .cpp file which was generated for your project. Feel free to hack it.

    SOURCES += main.cpp

    Installation path

    target.path =

    Please do not modify the following two lines. Required for deployment.

    include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
    qtcAddDeployment()

    OTHER_FILES +=
    android/AndroidManifest.xml
    android/res/layout/splash.xml
    android/res/values/libs.xml
    android/res/values/strings.xml
    android/res/values-de/strings.xml
    android/res/values-el/strings.xml
    android/res/values-es/strings.xml
    android/res/values-et/strings.xml
    android/res/values-fa/strings.xml
    android/res/values-fr/strings.xml
    android/res/values-id/strings.xml
    android/res/values-it/strings.xml
    android/res/values-ja/strings.xml
    android/res/values-ms/strings.xml
    android/res/values-nb/strings.xml
    android/res/values-nl/strings.xml
    android/res/values-pl/strings.xml
    android/res/values-pt-rBR/strings.xml
    android/res/values-ro/strings.xml
    android/res/values-rs/strings.xml
    android/res/values-ru/strings.xml
    android/res/values-zh-rCN/strings.xml
    android/res/values-zh-rTW/strings.xml
    android/src/org/kde/necessitas/ministro/IMinistro.aidl
    android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl
    android/src/org/qtproject/qt5/android/bindings/QtActivity.java
    android/src/org/qtproject/qt5/android/bindings/QtApplication.java
    android/version.xml
    @

    In addition to switching from QGuiApplication to QApplication, it's also necessary to add QT += widgets to the .pro file.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.