Displaying QT widgets in QML
-
Hi
I have the problem to have some old QT-widget-style applications, which should be wrapped by QML.
Currently the old Main-Class I have to call is the following:
@
class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);@I registered that one the following way
@qmlRegisterType<MainWindow>("Umbenennung",1,0,"Umbenennen");@
The I made a QML-File in the following way
@import Qt 4.7
import Umbenennung 1.0Umbenennen
{}@
When I call this one, the old HMI is displayed
However, if I start to do something like this:
@import Qt 4.7
import Umbenennung 1.0Item
{
id: testerUmbenennen { }
}
@
the program crashes. The constructor of MainWindow was allready finished.
Is there a way to wrap such kind of code inside QML without making changes on the old code?
Or is there an other way to call such programs?This was the callstack of the crash:
@0 QWidgetPrivate::invalidateGraphicsEffectsRecursively() /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1075b66
1 QWidgetPrivate::setDirtyOpaqueRegion() /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1075be4
2 QWidgetPrivate::updateIsOpaque() /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x107d025
3 QWidgetPrivate::setPalette_helper(QPalette const&) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x107d659
4 QWidgetPrivate::resolvePalette() /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x107d6ea
5 QWidgetPrivate::propagatePaletteChange() /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x107d4e3
6 QWidgetPrivate::setPalette_helper(QPalette const&) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x107d651
7 QWidgetPrivate::resolvePalette() /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x107d6ea
8 QWidget::event(QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x108250f
9 QMenuBar::event(QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x14fba5f
10 QApplicationPrivate::notify_helper(QObject*, QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1023c6c
11 QApplication::notify(QObject*, QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1029669
12 QCoreApplication::notifyInternal(QObject*, QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c4fc5b
13 QWidget::ensurePolished() const /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x10778cb
14 QWidget::ensurePolished() const /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1077911
15 QWidget::event(QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1082128
16 QMainWindow::event(QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x14c46d7
17 QApplicationPrivate::notify_helper(QObject*, QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1023c6c
18 QApplication::notify(QObject*, QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1029669
19 QCoreApplication::notifyInternal(QObject*, QEvent*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c4fc5b
20 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c52f1c
21 QCoreApplication::sendPostedEvents(QObject*, int) /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c5307d
22 ?? /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c7e964
23 g_main_context_dispatch /lib/libglib-2.0.so.0 0 0x22d85e5
24 ?? /lib/libglib-2.0.so.0 0 0x22dc2d8
25 g_main_context_iteration /lib/libglib-2.0.so.0 0 0x22dc4b8
26 QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c7e455
27 ?? /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x10e50b5
28 QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c4e709
29 QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c4eb8a
30 QCoreApplication::exec() /usr/local/Trolltech/Qt-4.7.1/lib/libQtCore.so.4 0 0x1c5313f
31 QApplication::exec() /usr/local/Trolltech/Qt-4.7.1/lib/libQtGui.so.4 0 0x1022987
32 main main.cpp 34 0x8056e5c@ -
Sorry, I do not get it. Can you give me some more information what you mean.
Maybe I had to mention that I'm a beginner in QT