Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • my application installed on drive D report error "cant not find Qt6WebEngineCore.dll"

    Unsolved
    1
    0 Votes
    1 Posts
    342 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • Question about connect() function with the SIGNAL and SLOT macros

    Solved
    5
    0 Votes
    5 Posts
    854 Views
    Pl45m4P
    @szmf To add: One more situation where you could face different behavior is when you are dealing with parent inside a QObject. Let's say your QObject has a fixed parent, which never changes (important) during its lifetime. Assume a signal foo() that is connected to a slot called bar() in your parent class. This works (besides it's not recommended or a good practise to do so): connect(this, SIGNAL(foo()), parent(), SLOT(bar()); while none of these work, for the same reason mentioned above: connect(this, &MyClass::foo, parent(), &ParentClass::bar); connect(this, &MyClass::foo, parent(), &QObject::bar); connect(this, &MyClass::foo, parentWidget(), &QWidget::bar); During compilation parent is not definite, therefore you would get an error that slot bar() can't be resolved / was not found. Whereas the first example works, as the check is performed at runtime where parent() is already linked to your actual parent class, which should hold a slot called bar().
  • qttexttospeech

    Unsolved
    3
    0 Votes
    3 Posts
    248 Views
    Ronel_qtmasterR
    @mondayboy [image: 64cca7d9-5d33-430a-8728-ae7179a24d13.PNG] in the demo here i have English and German
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • QComboBox width would changed when it setstylesheet

    Solved
    6
    0 Votes
    6 Posts
    912 Views
    HansonH
    @Abderrahmene_Rayene Oh!!!!It works!!!Thank you so much!!!
  • Qt Designer custom widget plugin confusion

    Unsolved
    2
    0 Votes
    2 Posts
    314 Views
    Christian EhrlicherC
    A plugin built with an older Qt version than the app wich is using this plugin is fine. It can not be newer for obvious reasons as the plugin might use a new api call.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • QPermission usage question

    Unsolved
    2
    0 Votes
    2 Posts
    312 Views
    C
    @RogueWarrior Not every platform a Qt application can be deployed on is Apple or Android. Even if your metadata indicates that your application wants GPS access I expect the user can deny it. So, on Mac for example, you appear to still need to check in code that permission is there. This is what I expect QPermission wraps in a platform-agnostic fashion.
  • QTcpServer won't receive client data on connected QTcpSocket

    Solved
    24
    0 Votes
    24 Posts
    3k Views
    D
    @dmitttri [SOLVED] I am posting the solution for the original post: Client had an issue, after socket write call it's required to call sync waitForBytesWritten, which will process actual socket writing Server had an issue, in the run method, we can't just call socket read, it's required to call waitForReadyRead which takes care to process socket and fill it with incoming data. Thanks everyone for their suggestions and help! I am also posting working sample code, which is only meant for demo purposes, to show a simple synchronous approach to TCP client and server DEMO TCP CLIENT AND SERVER WITH THREADS MainClient.cpp #include "SimpleClient.h" int main(int argc, char *argv[]) { SimpleClient client; if (!client.connectToServer("127.0.0.1", 9000)) { return -1; } if (!client.pokeServer("Hello Server")) { return -1; } return 0; } SImpleClient.h #ifndef SIMPLECLIENT_H #define SIMPLECLIENT_H #include <QTcpSocket> #include <QAbstractSocket> #define SOCKET_OPERATION_TIMEOUT_MS 3000 class SimpleClient { public: SimpleClient(); bool connectToServer(QString serverIP, qint16 serverPort); int pokeServer(const char *pokeMsg); private: QTcpSocket *socket = nullptr; }; #endif // SIMPLECLIENT_H SImpleClient.cpp #include <QByteArray> #include "SimpleClient.h" SimpleClient::SimpleClient() { this->socket = new QTcpSocket; } bool SimpleClient::connectToServer(QString serverIP, qint16 serverPort) { qDebug() << "Connecting to" << serverIP << ":" << serverPort; socket->connectToHost(QHostAddress(serverIP), serverPort); if (!socket->waitForConnected(SOCKET_OPERATION_TIMEOUT_MS)) { qDebug() << socket->errorString(); return false; } qDebug() << "Connected"; return true; } int SimpleClient::pokeServer (const char *pokeMsg) { qDebug() << "Sending :" << QString(pokeMsg); this->socket->write(pokeMsg, strlen(pokeMsg)); if (!this->socket->waitForBytesWritten(SOCKET_OPERATION_TIMEOUT_MS)) { qDebug() << socket->errorString(); return false; } if (!this->socket->waitForReadyRead(SOCKET_OPERATION_TIMEOUT_MS)) { qDebug() << this->socket->errorString(); return false; } QByteArray serverReply = this->socket->readAll(); QString replyString(serverReply.data()); qDebug() << "Received:" << replyString; qDebug() << "Success"; return true; } MainServer.cpp #include <QCoreApplication> #include <QtCore> #include "SimpleServer.h" int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); SimpleServer server; server.start("127.0.0.1", 9000); return app.exec(); } SimpleServer.h #ifndef SIMPLESERVER_H #define SIMPLESERVER_H #include <QDebug> #include <QTcpServer> class SimpleServer : public QTcpServer { Q_OBJECT; public: SimpleServer(QObject *parent = nullptr); bool start(QString serverIP, qint16 serverPort); protected: void incomingConnection(qintptr socketDescriptor) override; \ }; #endif // SIMPLESERVER_H SimpleServer.cpp #include <QHostAddress> #include "SimpleServer.h" #include "ServerJobThread.h" SimpleServer::SimpleServer(QObject *parent) : QTcpServer(parent) {} bool SimpleServer::start(QString serverIP, qint16 serverPort) { qDebug() << "Awaiting for new connections " << "IP" << serverIP << "PORT" << serverPort; this->listen(QHostAddress(serverIP), serverPort); return true; } void SimpleServer::incomingConnection(qintptr socketDescriptor) { qDebug() << "New incoming connection"; ServerJobThread *thread = new ServerJobThread(socketDescriptor, this); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); thread->start(); } ServerJobThread.h #ifndef SERVERJOBTHREAD_H #define SERVERJOBTHREAD_H #include <QThread> #include <QTcpSocket> class ServerJobThread : public QThread { Q_OBJECT public: ServerJobThread(qintptr socketDescriptor, QObject *parent); void run() override; private: qintptr socketDescriptor; }; #endif // SERVERJOBTHREAD_H ServerJobThread.cpp #include <QByteArray> #include <QTime> #include "ServerJobThread.h" #define SOCKET_OPERATION_TIMEOUT_MS 3000 #define THREAD_MAX_RUNNING_TIME_S 5 #define THREAD_ID this->currentThreadId() ServerJobThread::ServerJobThread(qintptr socketDescriptor, QObject *parent) : QThread(parent) { this->socketDescriptor = socketDescriptor; } void ServerJobThread::run() { bool workerThreadShouldRun = true; QTcpSocket tcpSocket; if (!tcpSocket.setSocketDescriptor(this->socketDescriptor)) { qDebug() << THREAD_ID << "setSocketDescriptor fail"; return; } QTime workerThreadTimeoutTime = QTime::currentTime().addSecs(THREAD_MAX_RUNNING_TIME_S); while (workerThreadShouldRun) { if (tcpSocket.bytesAvailable() == 0) { tcpSocket.waitForReadyRead(SOCKET_OPERATION_TIMEOUT_MS); } else { QByteArray buffer = tcpSocket.readAll(); if (buffer.size() > 0) { qDebug() << THREAD_ID << "Received:" << QString(buffer.data()); qDebug() << THREAD_ID << "Sending :" << QString("Hello Client"); tcpSocket.write("Hello Client"); tcpSocket.waitForBytesWritten(SOCKET_OPERATION_TIMEOUT_MS); workerThreadShouldRun = false; } if (QTime::currentTime() > workerThreadTimeoutTime) { qDebug() << THREAD_ID << "Thread max running time expired"; workerThreadShouldRun = false; } } } qDebug() << THREAD_ID << "Thread finished"; } CMakeLists.txt cmake_minimum_required(VERSION 3.14) project(Simple-TCP-Client-Server LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS core Network) add_executable(Server ServerJobThread.h ServerJobThread.cpp SimpleServer.h SimpleServer.cpp MainServer.cpp ) target_link_libraries(Server Qt6::Core Qt6::Network) add_executable(Client SimpleClient.h SimpleClient.cpp MainClient.cpp ) target_link_libraries(Client Qt6::Core Qt6::Network) CLIENT STDOUT $ ./Client Connecting to "127.0.0.1" : 9000 Connected Sending : "Hello Server" Received: "Hello Client" Success SERVER STDOUT $ ./Server Awaiting for new connections IP "127.0.0.1" PORT 9000 New incoming connection 0x9a60 Received: "Hello Server" 0x9a60 Sending : "Hello Client" 0x9a60 Thread finished
  • Project ERROR: This module does not accept configure command line arguments.

    Unsolved
    2
    0 Votes
    2 Posts
    240 Views
    SGaistS
    Hi and welcome to devnet, From the looks of it, I think it's thé -I and -L arguments that are wrong. If memory serves well, there's a space unlike when you pass them to the compiler. That said, why use OpenSSL ? macOS provides their implemention of secure transport.
  • Back to "sender()" analysis...

    Unsolved
    4
    0 Votes
    4 Posts
    465 Views
    Axel SpoerlA
    @AnneRanch said in Back to "sender()" analysis...: How can I fix this: sender()always returns a QObject *. If you want to access members of a class inheriting from QObject, e.g. MainWindow_Bluetooth, qobject_cast is your friend. It's documentation is here.
  • QPlainTextEdit internal padding

    Solved
    3
    0 Votes
    3 Posts
    427 Views
    W
    @mpergand Yep. Their solution worked: textEdit->document()->setDocumentMargin(0);
  • Remote Debugging with CDB chooses wrong Bit version

    Unsolved
    4
    0 Votes
    4 Posts
    380 Views
    InTheBeningingI
    Whats also odd is that in the debug output it says dStart parameters: '' mode: 6 ... dProject: C:\Program Files\Windows Kits\10\Debuggers\x64 In Start parameters should actually be my applications name and in Project the path of the executable instead of the debugger. In the example of the local debug session the values are set correctly. This seems to be a bug, i guess?
  • Js function running so slow in qml6

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    piervalliP
    @Aminsl Yes,
  • How to add a layout in the QTextEdit.

    Unsolved
    6
    0 Votes
    6 Posts
    568 Views
    M
    @nicker-player said in How to add a layout in the QTextEdit.: if i moved the middle button of the mouse,the scroll of the QTextEdit moved ,not the scrollArea widget move When the scroll of the text edit reach the bottom, the scroll of the main widget begins. To be honest, nested scroll areas are very bad design.
  • Window steals focus

    Unsolved focus
    9
    0 Votes
    9 Posts
    8k Views
    Z
    @raven-worx said in Window steals focus: when you call show() on your widgets before setting the parent. So they result in a separate window for a short period of time. This! Have been looking for my focus problem for a while now, and this was what I missed. Thanks!
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • 0 Votes
    9 Posts
    734 Views
    Q
    @jsulm yes thanks now my application show the ui.