[Qt-qml] qml and qt4.7 declarative component

Kumar vaibhav vaibhav_cs_kumar at yahoo.co.in
Tue Aug 24 11:33:17 CEST 2010


Hi

i am having problem with Qt 4.7 "QDeclrativeView" component which comes with Qt 
4.7

following are the files of my test application

///////////////////////////////////////////////////// project 
file/////////////////////////////////////////////////
QT       += core gui
QT +=  declarative

TARGET = untitled7
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h \
    test.h

FORMS    += mainwindow.ui

OTHER_FILES += \
    vaibhav.qml


///////////////////////////////////////////////////////// mainwindow.h 
file/////////////////////////////

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

/////////////////////////////////////////////// 
test.h////////////////////////////////////////////

#ifndef TEST_H
#define TEST_H
#include<QDebug>
#include <QObject>
class testheader : public QObject
{

    Q_OBJECT
    Q_INVOKABLE void callfromqml()
    {
        qDebug()<<"function called";
    }
};

#endif // TEST_H

////////////////////////////////////////////////////////////mainwindow.cpp///////////////////////////////////


#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


/////////////////////////////////////////////// 
main.cpp//////////////////////////////////////////

#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}


///////////////////////////////////////////////// 
vaibhav.qml//////////////////////////////////////////

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100824/ec83260c/attachment.html 


More information about the Qt-qml mailing list