Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.5k Posts
  • how to move the cancel button in QProgressDialog?

    Unsolved
    5
    0 Votes
    5 Posts
    593 Views
    D
    If I apply no stylesheet, then it uses a standard macOS progress bar which is much thinner vertically so the spacing looks better. I would expect the spacing due to the layout to compensate for the vertical size when I change it using the style sheet.
  • TERMINAL IS CALLED AFTER DEPLOY

    Solved
    3
    0 Votes
    3 Posts
    214 Views
    T
    It wasn't check
  • with my activex control, IE process not quit after close window/pages

    Unsolved
    1
    0 Votes
    1 Posts
    136 Views
    No one has replied
  • I use QThread but UI is frozen

    Unsolved
    2
    0 Votes
    2 Posts
    187 Views
    Chris KawaC
    You're calling scaner.scan directly on the ui thread so it's blocking. Moving an object to another thread doesn't mean its members are gonna be run there when invoked directly. To run it on the worker thread either use signal/slot or QMetaObejct::invokeMethod. Btw. you should really check if ind is not empty before calling last() on it.
  • How to connect 2 QCombobox by focus?

    Solved
    2
    0 Votes
    2 Posts
    173 Views
    gde23G
    look in the documentation to see the signals that QComboBox provides I guess currentIndexChanged(int index) is what you should use. However, the focussing of the "next" widget typically is not done by signals/slots that set some focus but by the tab order, see here on how to specify tab order.
  • Saving data in a file is too slow

    Unsolved
    14
    0 Votes
    14 Posts
    2k Views
    Kent-DorfmanK
    If you learn nothing else, understand that file IO speeds are not guaranteed. If is dependent upon the OS level IO your system supports, availaiblity of buffer/cache, and physical write speeds of the media. Waht happens when you compare the write speeds of rotational disk to an SSD and then to a ramdisk?...and like others said...don't open/close the file on every transaction
  • how to add pictures to a qt widget table in qt

    Solved
    18
    0 Votes
    18 Posts
    2k Views
    T
    thank you so much <3
  • Why QHash::iterator's operator+() was declared obsolet in 5.15?

    Unsolved
    3
    0 Votes
    3 Posts
    229 Views
    Christian EhrlicherC
    The function simply makes no sense - QHash is unordered so what do you want from this operator?
  • 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
    595 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
    679 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
    342 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