PyQtMobility problem



  • I. Introduction
    I want to load QML file with Video element from python file based on PyQt library. I have problem trying to use QtMultimediaKit. I use Windows Vista and I have:

    1. qt-sdk-win-opensource-2010.05.exe
    2. python-2.6.2.msi
    3. PyOpenGL-3.0.1.win32.exe
    4. lxml-2.2.8.win32-py2.6.exe
    5. PyQt-Py2.6-x86-gpl-4.8.4-1.exe
      (I also have PySide-1.0.0beta3qt471.win32-py2.6.exe and mutagen-1.20.tar.gz)

    II. Problems
    II.1. So I decided to try PyQtMobility and I downloaded qt-mobility-opensource-src-1.1.3.zip. There is no qt-mobility-opensource.exe installer so when I tried to install QtMobility I had first problem.
    When I compiled QtMobility I needed to configure QtMobility but I found that configure script took all values from sipconfig.py and pyqtconfig.py but I installed all QT and python libs to disk D: and it looks like sipconfig.py and pyqtconfig.py files contain paths point at disk C: and use VC compiler. I changed these files (sipconfig.py and pyqtconfig.py) – now paths point at disk D: and use win32-g++ compiler.
    After installation of QtMobility I added Video element to QML file. Here is QML file:

    @import Qt 4.7
    import QtMultimediaKit 1.1
    Rectangle {
    width: 850
    height: 650
    Video {
    id: video
    anchors.horizontalCenter: parent.horizontalCenter
    y: 50
    width : 640
    height : 480
    source: "Butterfly.wmv"
    playing: true

    }
    focus: true
    Keys.onSpacePressed: video.paused = !video.paused
    //Keys.onLeftPressed: video.position -= 5000
    //Keys.onRightPressed: video.position += 5000
    

    }
    @

    Everything works in QtCreator as well in qmlviewer but in QtCreater “import QtMultimediaKit 1.1" and “Video” element are underlined, like there are some errors. So first question – how could I force QtCreator to recognize installed QtMultimediaKit?

    II.2. I made CPP file to load QML file:

    @#include <QApplication>
    #include <QDeclarativeView>
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QDeclarativeView view;
    view.setSource(QUrl::fromLocalFile("video.qml"));
    view.show();
    return app.exec();
    }
    @

    It works well. Then I decided to use Python instead of CPP and I downloaded PyQtMobility-gpl-1.0.1.zip and I configured PyQtMobility (I need QtMultimediaKit only)
    python configure.py -n D:\Qt\2010.05\QtMobility\include\ -o D:\Qt\2010.05\QtMobility\lib\ -e QtMultimediaKit
    After installation QtMobility (at least I think so) I tried to run python file:

    @import sys
    import os
    from PyQt4 import QtCore, QtGui, QtDeclarative

    if name == 'main':

    app = QtGui.QApplication(sys.argv)
    view = QtDeclarative.QDeclarativeView()
    
    
    view.setSource(QtCore.QUrl.fromLocalFile&#40;'video.qml'&#41;&#41;
    
    view.show()
    sys.exit(app.exec_())
    

    @

    But I got error:

    video.qml:2:1: module "QtMultimediaKit" is not installed
    import QtMultimediaKit 1.1
    ^

    Thus video.qml file works in QtCreator, qmlviewer, CPP file but it doesn’t work in python file.
    What I tried as well, I added line to my python file:

    @from PyQt4.QtMobility import QtMultimediaKit@

    but I got another error:

    Traceback (most recent call last):
    File "main.py", line 8, in <module>
    from PyQt4.QtMobility import QtMultimediaKit
    ImportError: DLL load failed: The specified procedure could not be found

    I understand that in some DLL file some function missed but I have no idea which DLL and which function. My PATH environment var contains:
    D:\Python26\Lib\site-packages\PyQt4;D:\Qt\2010.05\mingw\bin;D:\Qt\2010.05\QtMobility\lib;D:\python26;D:\python26\Scripts;D:\python26\lib;D:\Qt\2010.05\qt\bin; D:\Qt\2010.05\bin
    I compared Qt files (QtCore4.dll, QtDeclarative4.dll etc) in 3 directories from PATH and found that QtFiles in these
    (D:\Python26\Lib\site-packages\PyQt4, D:\Qt\2010.05\qt\bin, D:\Qt\2010.05\bin) directories have different sizes, why? I tried to remove QT files from D:\Qt\2010.05\qt\bin, D:\Qt\2010.05\bin and after that QtCreator and qmlviewer stoped to work. So it seems to me in qt-sdk-win-opensource-2010.05.exe and PyQt-Py2.6-x86-gpl-4.8.4-1.exe there are different Qt files. And even inside qt-sdk-win-opensource-2010.05.exe there two directories with different Qt files.
    Second question - Maybe I didn’t install PyQtMobility (and maybe QtMobility as well) properly? but I don’t know what to do to load QML file with Video element from my python?



  • Make sure you have all modules necessary to QML, installed inside of the folder imports on you QT path.
    On linux the default path is "/usr/lib/qt4/imports" on windows depends of which Qt your python bindings use.

    On PySide I know we have a qt copy inside of PySide packages, then make sure if you have copied all QtMobility imports files to the PySide imports folder.

    This should works



  • [quote author="renato.filho" date="1305487864"]Make sure you have all modules necessary to QML, installed inside of the folder imports on you QT path.
    On linux the default path is "/usr/lib/qt4/imports" on windows depends of which Qt your python bindings use.

    On PySide I know we have a qt copy inside of PySide packages, then make sure if you have copied all QtMobility imports files to the PySide imports folder.
    [/quote]
    It's not clear for me, you try to help me with first or second problem?
    Actually I would like to use PyQt instead of PySide.
    I checked my D:\Qt\2010.05\qt\imports\ folder where there are:
    Qt, QtMobility, QtMultimediaKit, QtWebKit

    D:\Python26\Lib\site-packages\PyQt4\imports\ folder contains only Qt and QtWebKit.
    I copied QtMobility and QtMultimediaKit (from D:\Qt\2010.05\qt\imports) into D:\Python26\Lib\site-packages\PyQt4\imports\ folder. But it doesn't work for me. Any suggestion?
    Anybody loaded QML file with Video element from python (PyQT) file?



  • I was talking about the first problem the QML script.

    As a PySide developer I know how this work with PySide. If you have copied the files this should works (I think works for PyQt too).



  • [quote author="renato.filho" date="1305551676"]I was talking about the first problem the QML script.

    As a PySide developer I know how this work with PySide. If you have copied the files this should works (I think works for PyQt too).
    [/quote]
    Ok, if I understood the idea properly, I need to check and compare QT files inside PyQt (PySide) directory and main QT directory where QMLviewer, CPP example work.



  • The point is: to avoid this kind of error when parsing the QML file:

    @
    video.qml:2:1: module “QtMultimediaKit” is not installed
    import QtMultimediaKit 1.1
    @

    you must have all necessaries files inside of "imports" directory of you PySide/PyQt installation.


Log in to reply
 

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