Results 1 to 3 of 3

Thread: Log In Page

  1. #1
    Join Date
    Mar 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Log In Page

    Hello, I'd like to ask question regarding connecting the QML to cpp, my goal is to send parameter from QML in forms of username and password to cpp, the cpp itself is connected with the GSoap. If the results return true, then the user can move to another page and if wrong username and password were send, nothing will happen; but at the mean time, I'd just show some text at the console screen. This is my code, please give me a clue of what i was lack at.
    Qt Code:
    1. //LogInPage
    2. import QtQuick 1.0
    3. import "comp"
    4.  
    5. Rectangle
    6. {
    7. id: mainWindow
    8. width: 360; height: 360
    9. signal dataRequired(string msg,string msg);
    10. function success() {console.log("connection done")}
    11. function fail() {console.log("fail")
    12. Image
    13. {
    14. id: backgroundAbout
    15. source: "comp/pic/background-about.jpg"
    16.  
    17. Text {
    18. id: text1
    19. x: 21
    20. y: 118
    21. width: 80
    22. height: 20
    23. text: "UserName:"
    24. font.family: "OCR A Extended"
    25. font.pixelSize: 24
    26. }
    27.  
    28. Text {
    29. id: text2
    30. x: 218
    31. y: 207
    32. width: 80
    33. height: 20
    34. text: "PassWord:"
    35. font.family: "OCR A Extended"
    36. font.pixelSize: 25
    37. }
    38.  
    39. TextInput
    40. {
    41. id: inputLogin
    42. text: ""
    43. x: 0
    44. y: 0
    45. width: 310
    46. height: 22
    47. selectionColor: "#ffffff"
    48. font.family: "OCR A Std"
    49. }
    50. }
    51.  
    52. Rectangle {
    53. id: rectangle2
    54. x: 13
    55. y: 234
    56. width: 310
    57. height: 22
    58. color: "#eecfcf"
    59. border.color: "#995757"
    60. TextInput {
    61. id: inputPass
    62. text: ""
    63. x: 1
    64. y: 1
    65. width: 310
    66. height: 22
    67. selectionColor: "#ffffff"
    68. font.family: "OCR A Extended"
    69. opacity: 1
    70. }
    71. opacity: 0.2
    72.  
    73. Text {
    74. id: text3
    75. x: 143
    76. y: 301
    77. width: 80
    78. height: 20
    79. text: "LogIn"
    80. font.family: "OCR A Extended"
    81. font.pixelSize: 25
    82. MouseArea
    83. {
    84. id: mouseareaLogIn
    85. anchors.fill: parent
    86. onPressed:
    87. {
    88. myObject.fungsiLogIn(inputLogin.text, inputPass.text}
    89. }
    90. }
    91. }
    92. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //main.cpp
    2. #include "mainwindow.h"
    3. //#include "ui_mainwindow.h"
    4. #include <qdeclarative.h>
    5. #include <QDeclarativeView>
    6. #include "loginwidget.h"
    7. #include <QDebug>
    8.  
    9. #include <QtCore/QCoreApplication>
    10. #include <QtDeclarative/QDeclarativeEngine>
    11. #include <QtDeclarative/QDeclarativeComponent>
    12. #include <QtDeclarative/QDeclarativeView>
    13. #include <QtDeclarative/QDeclarativeContext>
    14. #include <QtCore/QVariant>
    15. #include <QtCore/QString>
    16. #include <QtCore/QMetaObject>
    17. #include "mainwindow.h"
    18.  
    19.  
    20.  
    21. MainWindow::MainWindow(QWidget *parent) :
    22. QMainWindow(parent)
    23.  
    24. {
    25. // QDeclarativeView view;
    26. this->login= new LoginWidget();
    27. this->view= new QDeclarativeView(this);
    28.  
    29. view->QDeclarativeView::setSource(QUrl::fromLocalFile("LogInPage.qml"));
    30. view->engine()->rootContext()->setContextProperty("myObject",&login);
    31. setCentralWidget(view);
    32. this->show();
    33.  
    34. }
    35.  
    36. MainWindow::~MainWindow()
    37. {
    38.  
    39. }
    40.  
    41. void MainWindow::test(char *username, char *password)
    42. {
    43. qDebug()<<" Passing done";
    44. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //mainwindow.cpp
    2. #include <QtGUI/QApplication>
    3. #include <QtCore/QCoreApplication>
    4. #include "loginwidget.h"
    5. //#include "loginpage.qml"
    6. #include <qdeclarative.h>
    7. #include <QDeclarativeView>
    8. #include "mainwindow.h"
    9.  
    10. int main(int argc, char *argv[])
    11. {
    12. QApplication app(argc, argv);
    13. MainWindow mainwindow;
    14. mainwindow.show();
    15.  
    16. return app.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //loginwidget.cpp
    2. #include "loginwidget.h"
    3. #include "QDebug"
    4. #include "Gsoap/testBinding.nsmap"
    5. #include <QDeclarativeView>
    6.  
    7. LoginWidget::LoginWidget()
    8. {
    9.  
    10. }
    11.  
    12. void LoginWidget::fungsiLogIn(char *username, char *password){
    13. char *output;
    14.  
    15. if ( clientSoap.ns2__functionLogin(*&username,*&password,*&output) == SOAP_OK)
    16. {
    17. if (output)
    18. {
    19. emit sukses();
    20. }
    21. else
    22. {
    23. emit gagal();
    24. }
    25.  
    26. }
    To copy to clipboard, switch view to plain text mode 

    Thank you for the aid.

    Regards,

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Log In Page

    Not to be rude but do you expect us to analyze and debug your code for you? You didn't even say how this code misbehaves with what you expect from it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Log In Page

    Sorry, I didn't mean to do so. I should have ask a more specific question. But by the way, it had been solved now, this is the link, just in case if anyone would want it: http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html

Similar Threads

  1. Cannot run example from Welcome Page
    By rox_rook in forum Installation and Deployment
    Replies: 6
    Last Post: 18th December 2010, 18:46
  2. How can I support page up/page down on QTextEdit
    By wesley in forum Qt Programming
    Replies: 7
    Last Post: 14th September 2010, 19:18
  3. Qt app and web page
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2009, 17:03
  4. QTabWidget remove a page at the page's request
    By thomaspu in forum Qt Programming
    Replies: 2
    Last Post: 29th December 2007, 20:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.