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. Question about QDataStream and its functions startTransaction and commitTransaction
Forum Updated to NodeBB v4.3 + New Features

Question about QDataStream and its functions startTransaction and commitTransaction

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 332 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.
  • J Offline
    J Offline
    Jc_Opc
    wrote on last edited by
    #1

    Hi,
    I found the following code in the example https://code.qt.io/cgit/qt/qtbase.git/tree/examples/network/fortuneclient/client.cpp?h=5.15,

    ...
    connect(tcpSocket, &QIODevice::readyRead, this, &Client::readFortune);
    ...
    void Client::readFortune()
    {
        in.startTransaction();
    
        QString nextFortune;
        in >> nextFortune;
    
        if (!in.commitTransaction())
            return;
    
        if (nextFortune == currentFortune) {
            QTimer::singleShot(0, this, &Client::requestNewFortune);
            return;
        }
    
        currentFortune = nextFortune;
        statusLabel->setText(currentFortune);
        getFortuneButton->setEnabled(true);
    }
    

    The issue I am having is in.commitTransaction() always return false, the size of the tcpsocket buffer keeps increasing and nextFortune size is always 0.

    Any help I really appreciate it.

    Thanks

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      So how do you send your data?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      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