Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt QML and SOAP
QtWS25 Last Chance

Qt QML and SOAP

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 3 Posters 8.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chronoske
    wrote on 9 Apr 2011, 05:37 last edited by
    #1

    Hi there, I'd like to ask regarding the QML Qt and SOAP, that is:

    Does the SOAP accessible directly through the QML? If so, is there any example code for me to study it?

    And a basic question that keeps bugging me, is Qt QML as strong as the Qt c++ or is it used only for designing the UI only??

    Thanks for your attention.
    Regards,

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on 9 Apr 2011, 07:57 last edited by
      #2

      Qt does not support SOAP out of the box. You need to use a 3rd party solution such as "kd-soap":http://www.kdab.com/kd-soap or "gsoap":http://www.cs.fsu.edu/~engelen/soap.html or roll your own.

      As for QML it is possible to write complete applications with only QML and javascript some things are accomplished more easily or comfortably in C++ still. It is up to you where you draw the line between what you do in QML/js and what you do in C++ as it depends upon your requirements.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on 9 Apr 2011, 08:01 last edited by
        #3

        Note that combining C++ Qt and QML is quite simple. There is no reason to make it hard on yourself and force yourself to do everything in QML when it is easier to do in C++, especialy if you already have working C++ code lying around.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chronoske
          wrote on 5 May 2011, 01:02 last edited by
          #4

          Thanks for the reply, I had to post phone my job due to my school..The SOAP has been connected successfully to the Qt, now what I need to do is connecting the Qml to the Qt.
          Thanks for your reply everyone!

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on 5 May 2011, 07:44 last edited by
            #5

            OK good. Feel free to come back if you have trouble with integrating C++ with QML and we'll try to help you out. It's not particularly difficult once you see how to do it.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            1 Reply Last reply
            0
            • C Offline
              C Offline
              chronoske
              wrote on 10 May 2011, 04:16 last edited by
              #6

              I found a new problem now.. The plan is to insert a username and password through the LogInPage.qml, and when we clicked the login button, I'd lilke to pass the value of username and password to the loginwidget.cpp where I could enter the logInFunction, this is my code:

              @//loginwidget
              #include "loginwidget.h"
              #include "QDebug"
              #include "Gsoap/testBinding.nsmap"

              LoginWidget::LoginWidget()
              {

              }

              void LoginWidget::fungsiLogIn(char username, char password){
              char output;
              if ( clientSoap.ns2__functionLogin(
              &username,
              &password,
              &output) == SOAP_OK)
              emit success();

              else
                  emit failed();   
              

              }
              @

              @//main.cpp
              #include <QtGUI/QApplication>
              #include <QtCore/QCoreApplication>
              #include "controllerdeclarativeview.h"
              #include "loginwidget.h"
              //#include "loginpage.qml"
              #include <qdeclarative.h>
              #include <QDeclarativeView>
              #include <QDeclarativeContext>

              int main(int argc, char *argv[])
              {

              QApplication app(argc, argv);

              qmlRegisterType<LoginWidget>("lib", 1, 0, "LoginWidget");
              

              controllerDeclarativeView w;
              w.show();
              return app.exec();
              }
              @

              @//part of the login.qml
              import QtQuick 1.0
              import lib 1.0

              Rectangle
              {
              id: mainWindow
              width: 360; height: 360
              ...
              LoginWidget {
              id: aLoginWidget
              anchors.centerIn: parent
              width: 100; height: 100
              color: "red"
              onsuccess: console.log("Succeeded")
              onfailed: console.log("Failed")
              }
              ...
              MouseArea
              {
              id: mouseareaLogIn
              width: 75
              height: 26
              anchors.rightMargin: 5
              anchors.bottomMargin: -6
              anchors.fill: parent
              onClicked: aLoginWidget.fungsiLogIn(inputLogin,inputPass)
              }
              @

              and two errors appear:
              'ui::main window' : no appropriate default constructor available

              and

              unable to recover from previous error; stopping compilation

              Any idea how to solved this?

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on 10 May 2011, 05:57 last edited by
                #7

                Take a look at the source for the Qt Dev Net client I am writing. I basically take the same approach there. You cna browse the source "here":https://websvn.theharmers.co.uk/listing.php?repname=Codes&path=/public/qtdevnetclient/trunk/ or get a local checkout by doing:

                @
                svn co https://svn.theharmers.co.uk/svn/codes/public/qtdevnetclient/trunk qtdevnet
                @

                The parts to look at are:

                • authenticator.[h,cpp]: This is the C++ class that actually performs the login using QNetworkAccessManager. The Authenticator::login() function is called from the next file...
                • main.qml: This is the master qml scene file. When the login button is clicked we call the Authenticator::login() function passing in the username and password contained in the LineEdit items.
                • mainwindow.cpp: In the constructor I expose the authenticator C++ object to the QML root context.

                It should all be fairly clear but let me know if you need any further help.

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  chronoske
                  wrote on 12 May 2011, 06:12 last edited by
                  #8

                  I still can't figured it out, here's my code:

                  @//controllerdeclarative.h
                  #ifndef CONTROLLERDECLARATIVEVIEW_H
                  #define CONTROLLERDECLARATIVEVIEW_H

                  #include <QtGui/QWidget>
                  #include <QtDeclarative/QDeclarativeView>

                  class controllerDeclarativeView : public QWidget
                  {
                  Q_OBJECT
                  public:
                  explicit controllerDeclarativeView(QWidget *parent = 0);
                  QDeclarativeView *view;

                  signals:

                  public slots:
                  };
                  #endif // CONTROLLERDECLARATIVEVIEW_H
                  @

                  @//loginwidget.h
                  #ifndef LOGINWIDGET_H
                  #define LOGINWIDGET_H
                  #include "Gsoap/soaptestBindingProxy.h" //
                  #include <QtGui/QWidget>
                  #include <QDeclarativeItem>

                  class LoginWidget:public QWidget
                  {
                  Q_OBJECT
                  public:
                  LoginWidget();

                  Q_INVOKABLE void fungsiLogIn(char *username,char *password);
                  

                  signals:
                  void success();
                  void fail();

                  private:
                  testBinding clientSoap;
                  };

                  #endif // LOGINWIDGET_H
                  @

                  @//mainwindow.h
                  #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:
                  };
                  #endif // MAINWINDOW_H
                  @

                  @//controllerdeclarativeview.cpp
                  #include "controllerdeclarativeview.h"

                  controllerDeclarativeView::controllerDeclarativeView(QWidget *parent) :
                  QWidget(parent)
                  {
                  this->view=new QDeclarativeView(this);
                  view->QDeclarativeView::setSource(QUrl::fromLocalFile("mammi_project.qml"));
                  this->view->QWidget::show();
                  }
                  @

                  @//loginwidget.cpp
                  #include "loginwidget.h"
                  #include "QDebug"
                  #include "Gsoap/testBinding.nsmap"

                  LoginWidget::LoginWidget()
                  {

                  }

                  void LoginWidget::fungsiLogIn(char username, char password){
                  char output;
                  if ( clientSoap.ns2__functionLogin(
                  &username,
                  &password,
                  &output) == SOAP_OK)
                  {
                  if (output)
                  emit success();
                  else
                  emit fail();

                  }
                  

                  }
                  @

                  @//main.cpp
                  #include <QtGUI/QApplication>
                  #include <QtCore/QCoreApplication>
                  #include "Gsoap/controllerdeclarativeview.h"
                  #include "loginwidget.h"
                  //#include "loginpage.qml"
                  #include <qdeclarative.h>
                  #include <QDeclarativeView>

                  int main(int argc, char *argv[])
                  {
                  QApplication app(argc, argv);

                  qmlRegisterType<LoginWidget>("mod", 1, 0, "LoginWidget");
                  

                  controllerDeclarativeView w;
                  w.show();
                  return app.exec();
                  }
                  @

                  @//mainwindow.cpp
                  #include "mainwindow.h"

                  MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent)

                  {

                  }

                  MainWindow::~MainWindow()
                  {

                  }
                  @

                  @//LogInPage.qml
                  import QtQuick 1.0
                  import "mod 1.0"

                  Rectangle
                  {
                  id: mainWindow
                  width: 360; height: 360
                  Image
                  {
                  id: backgroundAbout
                  source: "comp/pic/background-about.jpg"

                      Text {
                          id: text1
                          x: 21
                          y: 118
                          width: 80
                          height: 20
                          text: "UserName:"
                          rotation: 0
                          font.family: "OCR A Extended"        
                      }
                  
                      Text {
                          id: text2
                          x: 218
                          y: 207
                          width: 80
                          height: 20
                          text: "PassWord:"
                          rotation: 0
                          font.family: "OCR A Extended"
                          font.pixelSize: 25
                      }
                  
                      LoginWidget {
                          id: asd
                          anchors.centerIn: parent
                          width: 50; height: 100
                          color: "red"
                          onsukses: console.log("login executed")
                      }
                          TextInput
                          {
                              id: inputLogin
                              text: ""
                              x: 0
                              y: 0
                              width: 310
                              height: 22
                              text: ""
                              opacity: 1
                              selectionColor: "#ffffff"
                              font.family: "OCR A Extended"
                          }
                      }
                  
                          TextInput {
                              id: inputPass
                              text: ""
                              x: 1
                              y: 1
                              width: 310
                              height: 22
                              text: ""
                              selectionColor: "#ffffff"
                              font.family: "OCR A Extended"
                              opacity: 1
                          }
                          
                  
                      Text {
                          id: text3
                          x: 143
                          y: 301
                          width: 80
                          height: 20
                          text: "LogIn"
                          font.family: "OCR A Extended"
                          font.pixelSize: 25
                          MouseArea
                          {
                              id: mouseareaLogIn
                              width: 75
                              height: 26
                              anchors.rightMargin: 5
                              anchors.bottomMargin: -6
                              anchors.fill: parent
                              onClicked: asd.fungsiLogIn(inputLogin,inputPass)
                              //onClicked: pageModel.pageRequested("MainScreen.qml")
                          }
                      }                          
                  }
                  

                  @

                  Did I miss something?

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    chronoske
                    wrote on 12 May 2011, 06:13 last edited by
                    #9

                    it's done, I used this link as reference: "http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html":

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved