Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.6k Posts
  • Master / slave dialogs - looking for an idea

    Unsolved
    4
    0 Votes
    4 Posts
    219 Views
    jsulmJ
    @AnneRanch said in Master / slave dialogs - looking for an idea: just single step - update MainWindow after Bluetooth scanner is "updated". In this case you do not need signals/slots. Add a public method to your second dialog which returns the data. When the second dialog is closed call that method to get the data.
  • QFileDialog and Filters

    Unsolved
    7
    0 Votes
    7 Posts
    596 Views
    JonBJ
    @Perdrix The usual rule is: if the Qt docs do not state explicitly what such-and-such a behaviour is, then there isn't a "defined/guaranteed" behaviour. Else the docs would have said so! People then look at the source code if they want to know what is really going on. And you're welcome to do that. It quite possibly will not change from however you see it now, but that is not a promise, so you act on it at your own risk.
  • Removing blank lines in editor

    Solved
    3
    0 Votes
    3 Posts
    680 Views
    A
    @JonB Thanks for the references. Funny - I did not want to ask Mrs Google for "code beautifier" . Was thinking it is not proper "technical term".
  • QTcpSocket / QTcpServer, two way communication

    Unsolved
    23
    0 Votes
    23 Posts
    4k Views
    SPlattenS
    Whats the live cycle of a connection with QTcpSocket? My client connects to the application which is listening, here is the client connection code: setSocketOption(QAbstractSocket::LowDelayOption, 1); //Get the I/P address QList<QHostAddress> lstAddresses = QNetworkInterface::allAddresses(); QString strIP; for( int i=0; i<lstAddresses.size(); i++ ) { if ( lstAddresses[i] != QHostAddress::LocalHost && lstAddresses[i].toIPv4Address() ) { strIP = lstAddresses[i].toString(); break; } } if ( strIP.isEmpty() == true ) { strIP = QHostAddress(QHostAddress::LocalHost).toString(); } //Connect to the Application qdbg() << "Connecting to: " << strIP << ":" << muint16XMLMPAMport; connectToHost(strIP, muint16XMLMPAMport); The port is 8124. This does connect to the server and sends a message with: void clsSocketClient::sendJSON(const QJsonObject& crobjJSON) { if ( isOpen() != true ) { return; } //Associate this TCP socket with the output data stream QByteArray arybytMsg; QDataStream dsOut(&arybytMsg, QIODevice::WriteOnly); dsOut.setVersion(clsJSON::mscintQtVersion); //Send message to data stream dsOut << QJsonDocument(crobjJSON).toJson(QJsonDocument::Compact); //Write message #if defined(DEBUG_SOCKETS) qint64 int64Written = #endif write(arybytMsg); #if defined(DEBUG_SOCKETS) QJsonDocument objDoc(crobjJSON); qdbg() << "clsSocketClient::sendJSON" << "[" << int64Written << "]:" << QString(objDoc.toJson(QJsonDocument::Compact)); #endif } This works and I can see that int64Written is > 0 in the Application Output. The server application receives this message and sends and Ack: bool blnDecodeHeartbeat(const QJsonObject& crobjJSON) { QJsonObject::const_iterator citrFound = crobjJSON.find(clsJSON::mscszModule); if ( citrFound == crobjJSON.end() ) { return false; } QString strModuleName = citrFound.value().toString(); clsModule* pModule = clsModule::pGetModule(strModuleName); if ( pModule == nullptr ) { return false; } pModule->updateHearbeat(); //Send acknowledge back to module QJsonObject objJSON; objJSON.insert(clsJSON::mscszModule, strModuleName); objJSON.insert(clsJSON::mscszMsgType, clsJSON::mscszAck); //Cast the socket to the required type emit pModule->sendJSON(objJSON); return true; } This decode is called the instance the message arrives from the client and the sending of the Ack message is always successful. The server later tries to send a message to the client which is not the result of receiving a message: void clsScriptHelper::notify(const QJsonObject& crobjModule ,QJsonObject objCmds) { QJsonObject::const_iterator citrFound = crobjModule.find(clsJSON::mscszModule); QString strModuleName; clsModule* pModule; if ( citrFound == crobjModule.end() ) { return; } strModuleName = citrFound.value().toString(); //Make sure the module is set in the message objCmds.insert(clsJSON::mscszModule, strModuleName); //Set command type objCmds.insert(clsJSON::mscszMsgType, clsJSON::mscszCmdNotify); //Look up the socket for the module pModule = clsModule::pGetModule(strModuleName); if ( pModule == nullptr || pModule->blnTxAllowed() != true ) { clsModule::sendLater(strModuleName, objCmds); return; } //Convert object into byte array for transmission emit pModule->sendJSON(objCmds); } The code to send Later: void clsModule::sendLater(const QString& crstrModule, const QJsonObject& crobjJSON) { mpSendLater::iterator itrList = clsModule::msmpSendLaterLst.find(crstrModule); QJsonObject* pobjJSON; if ( itrList != clsModule::msmpSendLaterLst.end() ) { pobjJSON = itrList->second; } else { pobjJSON = new QJsonObject(); if ( pobjJSON != nullptr ) { clsModule::msmpSendLaterLst.insert(std::make_pair(crstrModule, pobjJSON)); } } if ( pobjJSON != nullptr ) { *pobjJSON = crobjJSON; #if defined(DEBUG_SOCKETS) QString strExpoded(clsJSON::strExplodeJSON(*pobjJSON, 0)); qdbg() << "clsModule::sendLater: " << strExpoded.toLatin1().data(); #endif } } The purpose of this function is that if the client is not connected or not ready then it inserts the message into a map that is supposed to be transmitted when the client next connects. When the client is connected the waiting messages are sent using the clsSocketClient::sendJSON as posted above, and this fails 100% of the time. Why? Its as if the client isn't ready to receive a message. Typical output in Application Output: D00000000000000000028T000000000915:clsJSON::commonDecode [50]: {"module":"mdFileIO","msgType":"init","port":8124} W00000000000000000029T000000001334:QProcess::setProgram: Process is already running D00000000000000000030T000000001334:Process: mdFileIO started, PID: 1046 D00000000000000000031T000000002816:clsJSON::commonDecode [49]: {"PID":"1046","module":"mdFileIO","msgType":"hb"} D00000000000000000032T000000002816:clsSocketClient::sendJSON[41]:{"module":"mdFileIO","msgType":"ack"} D00000000000000000033T000000002816:clsSocketClient::onBytesWritten:41 D00000000000000000034T000000004718:clsJSON::commonDecode [49]: {"PID":"1046","module":"mdFileIO","msgType":"hb"} D00000000000000000035T000000004718:clsSocketClient::sendJSON[41]:{"module":"mdFileIO","msgType":"ack"} D00000000000000000036T000000004718:clsSocketClient::onBytesWritten:41
  • How to write entire QVector to a binary file?

    Unsolved qvector binary format qdatastream
    46
    0 Votes
    46 Posts
    18k Views
    jsulmJ
    @CJha said in How to write entire QVector to a binary file?: If it's a copy then I assume it is always going to be the data No, because Qt containers use copy-on-write. See https://doc.qt.io/qt-5/implicit-sharing.html
  • QFileDialog has memory

    Unsolved
    4
    0 Votes
    4 Posts
    342 Views
    jsulmJ
    @Perdrix @JonB I could not find anything. A change request in Qt bug-tracker would make sense.
  • Segmentation fault using .dll compiled with Qt

    Solved dll seg fault
    5
    0 Votes
    5 Posts
    1k Views
    M
    Hi, It works thanks :)
  • What's new in static build qt 5.15.2 with msvc2019, win 10 ?

    Solved
    2
    0 Votes
    2 Posts
    382 Views
    F
    I solved the problem, i configured and compiled in the qtbase directory, and i needed to go up one level to the "Src" directory
  • How to create a cross platform microphone device using QT?

    Solved
    5
    0 Votes
    5 Posts
    397 Views
    A
    @SGaist said in How to create a cross platform microphone device using QT?: Then you will have to go platform specific. That's the kind of stuff that is outside of Qt's scope. True, thank you :)
  • Screen Resolution

    Unsolved
    3
    0 Votes
    3 Posts
    343 Views
    SGaistS
    Hi and welcome to devnet, Please check the Layout Management chapter in Qt's documentation.
  • Building MQTT module for Windows

    Solved
    3
    0 Votes
    3 Posts
    484 Views
    D
    Wow thank you ... I had been using the version corresponding to my Qt creator version not my MinGw version so that was the issue... Thank you so much for pointing it out so rapidly... It would have taken me a while to figure it out.
  • Mouse Click and keypressed not working in the Pathview

    Unsolved
    1
    0 Votes
    1 Posts
    92 Views
    No one has replied
  • Manage a local database without using queries

    Unsolved
    8
    0 Votes
    8 Posts
    354 Views
    D
    Thanks a lot to everyone; I was looking for something integrated into Qt; @SGaist I had seen other similar libraries before, however the one you recommended to me seems very interesting, I will definitely take a look it. Thanks again.
  • Any news on Qt update to support macOS Big Sur, 11.0.1?

    Unsolved
    4
    0 Votes
    4 Posts
    409 Views
    SGaistS
    What I meant is that there are already several issue that have been reported regarding Big Sur so you can check on them.
  • Widget Styling

    Solved
    3
    0 Votes
    3 Posts
    207 Views
    A
    Perfect. Thank you
  • how to implement in-process axserver as singleton

    Solved
    1
    0 Votes
    1 Posts
    148 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • transition in QPushButton change from normal to hover and pressed:

    Solved
    2
    0 Votes
    2 Posts
    3k Views
    Pl45m4P
    @nullbuil7 said in transition in QPushButton change from normal to hover and pressed:: in half a second Please explain. Stylesheets have no time based functions. If you want to change the stylesheet half a second later after you hovered your button, you will need to do that with some QTimer. transition in QPushButton change from normal to hover and pressed There is no real "transition". You could theoretically hover your cursor over one button for years without clicking it. Click and Hover are two independent actions. Ok, your cursor needs to be inside your button's rect in order to click, which is some "hovering"... So start the QTimer when your mouse enters your button and then adjust your stylesheet or start some QPropertyAnimation https://doc.qt.io/qt-5/qpropertyanimation.html https://doc.qt.io/qt-5/qwidget.html#enterEvent
  • Qt 6.0 C++ 11 version support. Will it be?

    Solved
    3
    0 Votes
    3 Posts
    635 Views
    B
    @jsulm Thx
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied