The server sending function:
void MainWindow::sendSpeed(int amp)
{
value = 255;
out << value;
// Send the linear slider value to the client
label->setNum(amp);
clientConnection->write(block);
statusBar->showMessage("Writing Data...", 100);
}
void MainWindow::sendSpeed(int amp)
{
QByteArray block;
QDataStream out(&block, QIODevice::ReadWrite);
value = 255;
out << value;
// Send the linear slider value to the client
label->setNum(amp);
clientConnection->write(block);
statusBar->showMessage("Writing Data...", 100);
}
To copy to clipboard, switch view to plain text mode
The client reading function:
void MainWindow::readSpeed()
{
quint8 sliderValue;
in >> sliderValue;
if (sliderValue == 0)
return;
slider->setAmpValue(sliderValue);
label->setNum(sliderValue);
}
void MainWindow::readSpeed()
{
QDataStream in(&tcpClient);
in.setVersion(QDataStream::Qt_4_0);
quint8 sliderValue;
in >> sliderValue;
if (sliderValue == 0)
return;
slider->setAmpValue(sliderValue);
label->setNum(sliderValue);
}
To copy to clipboard, switch view to plain text mode
Pretty much how it works is that the valueChanged() signal from the slider is connected to the sendSpeed() slot, and tracking is turned on for the slider. The client's readyRead() signal is connected to the client's readSpeed() slot
Bookmarks