Q_INVOKABLE
void login_database
(const QString &userin,
const QString &passin
){
if(db.isOpen())
{
querylogin.exec("SELECT * FROM hospital WHERE UserName=\'"+userin+"\'");
if(!querylogin.exec())
{
}
else
{
bool matchPass=FALSE;
bool matchUname=FALSE;
while (querylogin.next())
{
Uname=querylogin.value(1).toString();
Pass = querylogin.value(2).toString();
if(Uname==userin)
matchUname=TRUE;
}
if(!matchUname)
{
}
else if(!matchPass)
{
// loginlbl->setText("Wrong Password");
return;
}
else
{
QDeclarativeEngine engine1;
QDeclarativeComponent component(&engine1, "main.qml");
QObject *object
= component.
create();
qDebug() << "QML function returned:" << returnedValue.toString();
delete object;
}
}
}
Q_INVOKABLE void login_database(const QString &userin,const QString &passin)
{
QSqlQuery querylogin(db);
if(db.isOpen())
{
querylogin.exec("SELECT * FROM hospital WHERE UserName=\'"+userin+"\'");
if(!querylogin.exec())
{
QMessageBox::information(this, tr("Login Match"),tr("Sorry query is not execute"),QMessageBox::Ok);
}
else
{
QString Pass,Uname;
bool matchPass=FALSE;
bool matchUname=FALSE;
while (querylogin.next())
{
Uname=querylogin.value(1).toString();
Pass = querylogin.value(2).toString();
if(Uname==userin)
matchUname=TRUE;
}
if(!matchUname)
{
QMessageBox::information(this, tr("Login Match"),tr("Invalid Username"),QMessageBox::Ok);
}
else if(!matchPass)
{
// loginlbl->setText("Wrong Password");
QMessageBox::information(this, tr("Login Match"),tr("Invalid Password"),QMessageBox::Ok);
return;
}
else
{
QMessageBox::information(this, tr("Login Match"),tr("Sucessfully ur login to database"),QMessageBox::Ok);
QDeclarativeEngine engine1;
QDeclarativeComponent component(&engine1, "main.qml");
QObject *object = component.create();
QVariant returnedValue;
QVariant msg = "Hello from C++";
QMetaObject::invokeMethod(object, "myQmlFunction",
Q_RETURN_ARG(QVariant, returnedValue),
Q_ARG(QVariant, msg));
qDebug() << "QML function returned:" << returnedValue.toString();
delete object;
}
}
}
To copy to clipboard, switch view to plain text mode
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
Rectangle {
id:hdcs_ui_login_rect1
width: 1600
height:900
// color:"red"
Image {
id: back
anchors.fill: parent
source: "img/backg.png"
cache: true
}
Rectangle{
id:outline
width: parent.width/1.2
height: parent.height/1.2
color: "transparent"
anchors.centerIn: parent
Image {
id:login
anchors.topMargin: 11
source: "img/doctors_26.png"
cache: true
}
Rectangle{
id:outline1
width: parent.width/2
height: parent.height/1.8
color: "transparent"
anchors.centerIn: parent
Image {
id:login1
anchors.topMargin: 11
anchors.fill: parent
// anchors.top:coll.top
source: "img/newimage1.png"
cache: true
}
Column
{
id:coll
anchors.centerIn: parent
spacing: 30
Column{
spacing: 5
Text {
id: title
text: qsTr("Login")
font.pixelSize: 30
color:"white"
font.bold: true
}
}
Column{
spacing: 5
Text {
id: name
text: qsTr("User Id:")
font.pixelSize: 20
color:"white"
}
Rectangle{
id:rect
width: 300
height: 30
color: "white"
TextInput
{
id: userInputlog
width: parent.width-6
height: parent.height-6
anchors.centerIn: parent
font.pixelSize: 15
font.bold: true
maximumLength: 15
}
}
}
Column
{
spacing: 5
Text {
id: passlog
text: qsTr("Password:")
font.pixelSize: 20
// font.bold: true
color:"white"
}
Rectangle{
id:rect1
width: 300
height: 30
color: "white"
TextInput
{
id: passwordInput
width: parent.width-6
height: parent.height-6
anchors.centerIn: parent
font.pixelSize: 15
font.bold: true
maximumLength: 15
echoMode: TextInput.Password
}
}
}
Rectangle{
// spacing: 100
id:buttons
width: parent.width
color: "transparent"
}
Row{
spacing: 20
anchors.horizontalCenter: parent.horizontalCenter
Image {
id: img
source: "img/re1.png"
fillMode: Image.PreserveAspectFit
Text {
id:log
text: qsTr("Login")
anchors.centerIn: parent
color:"white"
font.pixelSize: 20
font.bold:true
}
function myQmlFunction(msg) {
console.log("Got message:", msg)
return "some return value"
}
MouseArea
{
anchors.fill: parent
onPressed:
{
myObject.login_database(userInputlog.text,passlog.text);
function myQmlFunction(msg) {
console.log("Got message:", msg);
if(msg == userInputlog.text)
{
loader.source = "HDCS_UI_DR_CHF.qml"
}
}
}
}
}
Image {
id: img1
source: "img/re1.png"
Text {
id:log2
anchors.leftMargin: 20
text: qsTr("Forgot Password")
anchors.centerIn: parent
color:"white"
font.bold: true
font.pixelSize: 20
}
}
}
}
}
}
Image {
id: shutdown
anchors.verticalCenterOffset: 350
anchors.horizontalCenterOffset: 550
anchors.horizontalCenter:parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
source: "img/power.png"
cache: true
smooth: true
MouseArea{
anchors.fill: parent
onClicked:
{
Qt.quit();
}
}
}
Loader {
id: loader
anchors.fill: parent
focus: true
}
}
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
Rectangle {
id:hdcs_ui_login_rect1
width: 1600
height:900
// color:"red"
Image {
id: back
anchors.fill: parent
source: "img/backg.png"
cache: true
}
Rectangle{
id:outline
width: parent.width/1.2
height: parent.height/1.2
color: "transparent"
anchors.centerIn: parent
Image {
id:login
anchors.topMargin: 11
source: "img/doctors_26.png"
cache: true
}
Rectangle{
id:outline1
width: parent.width/2
height: parent.height/1.8
color: "transparent"
anchors.centerIn: parent
Image {
id:login1
anchors.topMargin: 11
anchors.fill: parent
// anchors.top:coll.top
source: "img/newimage1.png"
cache: true
}
Column
{
id:coll
anchors.centerIn: parent
spacing: 30
Column{
spacing: 5
Text {
id: title
text: qsTr("Login")
font.pixelSize: 30
color:"white"
font.bold: true
}
}
Column{
spacing: 5
Text {
id: name
text: qsTr("User Id:")
font.pixelSize: 20
color:"white"
}
Rectangle{
id:rect
width: 300
height: 30
color: "white"
TextInput
{
id: userInputlog
width: parent.width-6
height: parent.height-6
anchors.centerIn: parent
font.pixelSize: 15
font.bold: true
maximumLength: 15
}
}
}
Column
{
spacing: 5
Text {
id: passlog
text: qsTr("Password:")
font.pixelSize: 20
// font.bold: true
color:"white"
}
Rectangle{
id:rect1
width: 300
height: 30
color: "white"
TextInput
{
id: passwordInput
width: parent.width-6
height: parent.height-6
anchors.centerIn: parent
font.pixelSize: 15
font.bold: true
maximumLength: 15
echoMode: TextInput.Password
}
}
}
Rectangle{
// spacing: 100
id:buttons
width: parent.width
color: "transparent"
}
Row{
spacing: 20
anchors.horizontalCenter: parent.horizontalCenter
Image {
id: img
source: "img/re1.png"
fillMode: Image.PreserveAspectFit
Text {
id:log
text: qsTr("Login")
anchors.centerIn: parent
color:"white"
font.pixelSize: 20
font.bold:true
}
function myQmlFunction(msg) {
console.log("Got message:", msg)
return "some return value"
}
MouseArea
{
anchors.fill: parent
onPressed:
{
myObject.login_database(userInputlog.text,passlog.text);
function myQmlFunction(msg) {
console.log("Got message:", msg);
if(msg == userInputlog.text)
{
loader.source = "HDCS_UI_DR_CHF.qml"
}
}
}
}
}
Image {
id: img1
source: "img/re1.png"
Text {
id:log2
anchors.leftMargin: 20
text: qsTr("Forgot Password")
anchors.centerIn: parent
color:"white"
font.bold: true
font.pixelSize: 20
}
}
}
}
}
}
Image {
id: shutdown
anchors.verticalCenterOffset: 350
anchors.horizontalCenterOffset: 550
anchors.horizontalCenter:parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
source: "img/power.png"
cache: true
smooth: true
MouseArea{
anchors.fill: parent
onClicked:
{
Qt.quit();
}
}
}
Loader {
id: loader
anchors.fill: parent
focus: true
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks