Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Conversion of std::string to qstring over Qdbus and Provide QDBusArgument streaming operators
Forum Updated to NodeBB v4.3 + New Features

Conversion of std::string to qstring over Qdbus and Provide QDBusArgument streaming operators

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.1k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    sruthihsr
    wrote on last edited by
    #1

    Hi All,

    I have a C++ application exposing methods which have structures with std:string as parameter.
    I would like to access these through Qtbus in my Qt application.
    Please let me know how do i write Provide QDBusArgument streaming operators (<< and >> definition)

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      One possibility is using "fromStdString":http://developer.qt.nokia.com/doc/qt-4.8/qstring.html#fromStdString for conversion.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sruthihsr
        wrote on last edited by
        #3

        I tried the folloing
        @
        const QDBusArgument &operator>>(const QDBusArgument &argument, abc &myabc) {
        argument.beginStructure();
        QString tempstr;
        argument >> tempstr >> myabc.availability;
        myabc.name=QString::toStdString(tempstr);
        argument.endStructure();
        return argument;
        }
        @
        I get the below error
        no matching function for call to ‘QString::toStdString(QString&)

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Basic C++ error. toStdString is not a static method.

          @
          myabc.name = tempstr.toStdStr();
          @

          http://www.catb.org/~esr/faqs/smart-questions.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