PDA

View Full Version : printer_pdf



ganeshgladish
20th June 2013, 07:30
hi,
i have created gui using qml....now i want to print this gui as pdf.....how can i do ...please help me....

wysota
20th June 2013, 08:34
Qt4 or Qt5?

ganeshgladish
20th June 2013, 10:28
thank you for your reply.....i am using Qt5

wysota
20th June 2013, 13:37
It might be a good idea to update your user profile here as it suggests you are usin Qt4 and Qt/Embedded.

Anyways.... QQuickWindow::grabWindow() is your friend.

ganeshgladish
20th June 2013, 16:14
i have hello.qml gui
like,

Rectangle{
id:gui
width:100
height:100
color:“red”
Text{
id:text
text:“Hello World”
font.bold:true
anchors.centerin:parent
} MouseArea{ anchors.fill: parent onClicked: myObject.print_pdf(); }
}

i have created Qdeclarative view for sending data to c++ function..

please see the mousearea function i have created onclicked finction,
in this onclicked function i want to send hello.qml to c++(print_pdf() function) …this function is in c++)

note: this myObject is Qdeclarative element name

my question is in this onclicked function how to send this hellow.qml to print_pdf function

wysota
20th June 2013, 17:19
Are you using QtQuick 2 or QtQuick 1?

ganeshgladish
22nd June 2013, 04:16
\
i am using QtQuick 2

ganeshgladish
22nd June 2013, 08:39
i have hello.qml gui
like,

Rectangle{
id:gui
width:100
height:100
color:“red”
Text{
id:text
text:“Hello World”
font.bold:true
anchors.centerin:parent
} MouseArea{ anchors.fill: parent onClicked: myObject.print_pdf(); }
}

i have created Qdeclarative view for sending data to c++ function..

please see the mousearea function i have created onclicked finction,
in this onclicked function i want to send hello.qml to c++(print_pdf() function) …this function is in c++)

note: this myObject is Qdeclarative element name

my question is in this onclicked function how to send this hellow.qml to print_pdf function...i want to print this hello.qml(gui) ...

wysota
22nd June 2013, 09:00
\
i am using QtQuick 2

Then why is your object a QDeclarativeSomething? classes starting with QDeclarative are part of QtQuick 1.

All you need to do is expose your object to QML using QQmlContext::setContextProperty()

ganeshgladish
22nd June 2013, 09:39
sorry wysota,

i am using QQuickView not declarative view...

this is my main.cpp ..

#include<QApplication>
#include"database.h"
#include<QCalendarWidget>
#include<QMetaObject>
#include"retrieve.h"
#include <QQuickView>
#include <QQmlContext>
#include <QGuiApplication>

user_list database_ret;

#include <QGuiApplication>
#include <QQuickView>
#include <QQmlEngine>
#include <QApplication>

int main(int argc, char* argv[])
{
QApplication app(argc,argv);
mainwindow window;
QQuickView * view1= new QQuickView();
view1->setResizeMode(QQuickView::SizeRootObjectToView);
view1->rootContext()->setContextProperty("myObject", &window);
view1->setSource(QUrl("hello.qml"));
view1->showFullScreen();
return app.exec();

}