ok. I will show you my code.
This is my Widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
namespace Ui {
class Widget;
}
{
Q_OBJECT
public:
explicit Widget
(QWidget *parent
= 0);
~Widget();
void ShowQML();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
void ShowQML();
void setText(QString);
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
To copy to clipboard, switch view to plain text mode
This is my Widget.cpp
#include "widget.h"
#include "ui_widget.h"
#include <QtGui>
#include <QDeclarativeComponent>
#include <QDeclarativeEngine>
#include <QDeclarativeItem>
#include <QDeclarativeView>
ui(new Ui::Widget)
{
ui->setupUi(this);
qDebug()<<"Inside cnstrctr";
}
void Widget::ShowQML()
{
QDeclarativeView *testView = new QDeclarativeView();
testView
->setSource
(QUrl::fromLocalFile("test2.qml"));
testView->show();
}
Widget::~Widget()
{
delete ui;
}
{
qDebug()<<"Inside slot in CPP";
//SendSignal();
}
#include "widget.h"
#include "ui_widget.h"
#include <QtGui>
#include <QDeclarativeComponent>
#include <QDeclarativeEngine>
#include <QDeclarativeItem>
#include <QDeclarativeView>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
qDebug()<<"Inside cnstrctr";
}
void Widget::ShowQML()
{
QDeclarativeView *testView = new QDeclarativeView();
testView->setSource(QUrl::fromLocalFile("test2.qml"));
testView->show();
}
Widget::~Widget()
{
delete ui;
}
void Widget::setText(QString msg)
{
qDebug()<<"Inside slot in CPP";
//SendSignal();
}
To copy to clipboard, switch view to plain text mode
this is the main file
#include <QtGui/QApplication>
#include "widget.h"
#include <qdeclarative.h>
#include <QDeclarativeView>
#include <QApplication>
#include <QBoxLayout>
int main(int argc, char *argv[])
{
qmlRegisterType<Widget>("File", 1,1, "TextUpdate");
Widget w;
//w.show();
w.ShowQML();
return a.exec();
}
#include <QtGui/QApplication>
#include "widget.h"
#include <qdeclarative.h>
#include <QDeclarativeView>
#include <QApplication>
#include <QBoxLayout>
int main(int argc, char *argv[])
{
qmlRegisterType<Widget>("File", 1,1, "TextUpdate");
QApplication a(argc, argv);
Widget w;
//w.show();
w.ShowQML();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
and the QML file is
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import File 1.1
Rectangle {
width: 100
height: 62
TextUpdate{
id: sample1
}
}
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import File 1.1
Rectangle {
width: 100
height: 62
TextUpdate{
id: sample1
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks