[Interest] view examples\declarative\cppextensions\qwidgets\qwidgets.qml using pySide or PyQt4

cckwes cckwes at gmail.com
Thu May 2 02:26:23 CEST 2013


Hi,

I think you need to expose you QWidget to QML using qmlRegisterType(). You
can refer to this post on how to do it. :)

http://qt-project.org/forums/viewthread/7616

Regards,
Wesley


On Thu, May 2, 2013 at 1:42 AM, Sergey <sh0375 at gmail.com> wrote:

> Hi,
>
> I've downloaded and installed
> ftp://ftp.qt.nokia.com/qt/source/qt-win-opensource-4.8.1-vs2008.exe
>
> examples\declarative\cppextensions\qwidgets\ is working well:
> D:\QT\4.8.1\bin\qmlviewer.exe qwidgets.qml
>
> But I can not make it working in pySide or PyQt4.
> I use http://releases.qt-project.org/pyside/PySide-1.1.2.win32-py2.7.exe
>
> This is python script:
> ---------------------------------------
> import sys
> import os
>
> from PySide import QtCore, QtGui, QtDeclarative
> basedir = os.path.dirname(os.path.realpath(__file__))
> app = QtGui.QApplication(sys.argv)
> view = QtDeclarative.QDeclarativeView()
> view.setSource(QtCore.QUrl(basedir + '/' + sys.argv[1]))
> view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView)
> ##view.setWindowIcon(QtGui.QIcon(basedir + '/icon.ico'))
> view.setWindowTitle('Simple Data')
> w=800
> h=600
> sw=QtGui.QApplication.desktop().screen().rect().width()
> sh=QtGui.QApplication.desktop().screen().rect().height()
> view.setGeometry((sw-w)/2, (sh-h)/2, w, h)
> view.show()
> sys.exit(app.exec_())
> ---------------------------------------
>
> gives error:
> D:\QT\4.8.1\examples\declarative\cppextensions\qwidgets/qwidgets.qml:42:1:
> import "QWidgets" has no qmldir and no namespace
>
> Same problem if use PyQt4.
>
> Is it possible to embed QWidget-based objects into QML in pySide or PyQT4?
>
>
> --
> Regards,
>
> Sergey
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



-- 
Wesley Chong

Email: cckwes at gmail.com
Blog: http://blog.linux4us.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130502/e9177627/attachment.html>


More information about the Interest mailing list