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. Keyword in

Keyword in

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.2k Views 2 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.
  • Nio74N Offline
    Nio74N Offline
    Nio74
    wrote on last edited by
    #1

    I can't understund how keyword work "in" can you explain it me?

    void ServerStuff::readClient()
    {
       // QTcpSocket *clientSocket = (QTcpSocket*)sender();
        QTcpSocket *clientSocket = static_cast<QTcpSocket*>(sender());
    
    **//do you need to pass the contents in clientSocket  to QdataStream?**
    
        QDataStream in(clientSocket);
        //in.setVersion(QDataStream::Qt_5_10);
        for (;;)
        {
            if (!m_nNextBlockSize)
            {
                if (clientSocket->bytesAvailable() < sizeof(quint16)) { break; }
                in >> m_nNextBlockSize;
            }
    
            if (clientSocket->bytesAvailable() < m_nNextBlockSize) { break; }
            QString str;
            in >> str;
    
            emit gotNewMesssage(str);
    
            m_nNextBlockSize = 0;
    
            if (sendToClient(clientSocket, QString("Reply: received [%1]").arg(str)) == -1)
            {
                qDebug() << "Some error occured";
            }
        }
    }
    
    
    
    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      in isn't a keyword. it is an object of type QDataStream. In the context you are using it it is a stream object to read from a socket using the streams operators.

      If you meet the AI on the road, kill it.

      Nio74N 1 Reply Last reply
      4
      • Kent-DorfmanK Kent-Dorfman

        in isn't a keyword. it is an object of type QDataStream. In the context you are using it it is a stream object to read from a socket using the streams operators.

        Nio74N Offline
        Nio74N Offline
        Nio74
        wrote on last edited by
        #3

        @Kent-Dorfman said in Keyword in:

        in isn't a keyword. it is an object of type QDataStream. In the context you are using it it is a stream object to read from a socket using the streams operators.

        thanks, in this way is passed to the object "in" as an argument (clientSocket)?

        jsulmJ 1 Reply Last reply
        0
        • Nio74N Nio74

          @Kent-Dorfman said in Keyword in:

          in isn't a keyword. it is an object of type QDataStream. In the context you are using it it is a stream object to read from a socket using the streams operators.

          thanks, in this way is passed to the object "in" as an argument (clientSocket)?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @Nio74 clientSocket is passed as parameter/argument to "in", so "in" will read from clientSocket

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          4
          • Nio74N Offline
            Nio74N Offline
            Nio74
            wrote on last edited by
            #5

            tanks everyone,I think that I have understund

            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