Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
84.1k Topics 460.6k Posts
Qt 6.12 LTS is out! See what's new in the release blog
  • Reporting inappropriate content on the forums

    Pinned Locked spam
    29
    4 Votes
    29 Posts
    57k Views
    A
    Thank you for the report. I have banned the user, which got rid of the spam posting. Not a loss, as this user did not post any other content on the site. Just deleting this one posting was not possible. Thanks for reporting this.
  • LGPLv3 compliance for PySide6 app distributed through Microsoft Store MSIX

    Unsolved
    1
    0 Votes
    1 Posts
    43 Views
    No one has replied
  • Qt Widgets or Qt Quick/QML for this application?

    Unsolved
    7
    0 Votes
    7 Posts
    2k Views
    M
    @Simmania I'm curious if you went down the rabbit hole on QML? :) It looks like your app is quite heavy on plotting and I'd be interested to learn more about your use case there. Is the app open source?
  • Checking if running as command-line (QCoreApplication) or GUI

    Unsolved
    14
    0 Votes
    14 Posts
    237 Views
    PerdrixP
    I still think the wording is open to my interpretation, however I have now defined my own convenience macro: // // Define a convenience macro for checking if we're using a Qt GUI or command line application // #define qtGUI (dynamic_cast<QApplication *>(QCoreApplication::instance()))
  • Deleting rows from QTableWidget

    Solved
    7
    0 Votes
    7 Posts
    122 Views
    J
    @Christian-Ehrlicher Ok, thank you, i'll read it
  • Slow Qt Widgets plotting over VNC on an ARM board (4–5 FPS)

    Unsolved arm vnc help
    2
    0 Votes
    2 Posts
    58 Views
    SGaistS
    Hi, Are you sure that it's not the network that is the bottleneck ? VNC is not exactly optimized for in terms of bandwidth. You might also want to check if you can tune the Xnvc server configuration to optimize for your use case.
  • qmake can't generator .stash file

    Unsolved
    9
    0 Votes
    9 Posts
    287 Views
    JonBJ
    @hello_tyggylpp I know nothing about this. But: You say your file is "incomplete" and stops at QMAKE_GCC_PATCH_VERSION. You say the "complete" file should have QMAKE_CXX.INCDIRS = ... next. You can see that the value for that as shown in your paste is "clearly" (at least to me) wrong QMAKE_CXX.INCDIRS = C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \ C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include C:/Qt/Qt5.14.2/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed C:/Qt/Qt5.14.2/Tools/mingw730_64/x86_64-w64-mingw32/include I have copied & pasted what you have written/pasted. You should always paste code/output into this forum inside the forum's code tags (the </> toolbar button or inside ``` or ` blocks). I suggest you repaste "the complete .qmake.stash file:" using the correct tags/verbatim if you want you/us to see whether it is indeed incorrect as it currently appears to be.
  • Getting Qt application to honour dark theme on Lubuntu 26.04.1

    Unsolved
    31
    0 Votes
    31 Posts
    2k Views
    S
    A different post I replied to surfaced a different idea: On Linux we are distributing our app as AppImage. This will package all dependencies into an executable image. It is not the ideal solution for Linux, but if you have a small software that is not included in official repositories of the distros it is the much better option for maintainability. This would package both Qt and libqtlxqt alongside your app. It also does not require any special installation. Though, once you go down that path it is quite easy to register your app through xdg. Here is roughly how we deploy our AppImage: #!/bin/bash LD_LIBRARY_PATH= # additional library paths if required export LD_LIBRARY_PATH chmod u+x linuxdeploy*.AppImage # on CI/CD this might not have the executable flag when checked out export VERSION=1.0.0 echo == Remove old AppDir. == rm -rf AppDir echo == Generate new AppDir. == ./linuxdeploy-x86_64.AppImage --appdir=AppDir --executable=../release/MyApp --desktop-file=MyApp.desktop --icon-file=MyApp.svg echo == Bundle Qt libs and create AppImage. == cd AppDir ../linuxdeployqt-6-x86_64.AppImage MyApp.desktop -qmake=/path/to/qmake -appimage echo == Done. == You'll see that we use both linuxdeploy and linuxdeployqt. This is at least what worked for us. These tools require you not to use the newest version of Linux because they want to ensure broad portability. I guess that LGPL conformance is given because the AppImage is just a regular image that can be mounted regularly and thus someone might be able to exchange the libraries inside it. Just for completeness sake: Besides AppImage there is also Snap and Flatpack. My research at the time brought me to AppImages.
  • QTcpSocket spamming EALREADY

    Unsolved
    9
    0 Votes
    9 Posts
    1k Views
    X
    Hello again. I'm still on this problem with some new findings and some clarifications on the topic. Firstly, I want to clean up the code I've posted before. So here is an updated class: socket_example.hpp class SocketExample : public QObject { Q_OBJECT public: SocketExample(); ~SocketExample(); bool Initialize(); private: QTcpSocket clientSocket; int timerId; bool clientBound; bool aboutToClose; protected: void timerEvent(QTimerEvent *) override; private slots: void onErrorOccurred(QTcpSocket::SocketError); void onStateChanged(QTcpSocket::SocketState); void onConnected(); void onReadyRead(); void onDisconnected(); void bindSocket(); } socket_example.cpp SocketExample::SocketExample() : clientSocket(this) , timerId(0) , clientBound(false) , aboutToClose(false) { connect(&clientSocket, &QTcpSocket::errorOccurred, this, &SocketExample::onErrorOccurred, Qt::ConnectionType::DirectConnection); connect(&clientSocket, &QTcpSocket::stateChanged, this, &SocketExample::onStateChanged, Qt::ConnectionType::DirectConnection); connect(&clientSocket, &QTcpSocket::connected, this, &SocketExample::onConnected, Qt::ConnectionType::DirectConnection); connect(&clientSocket, &QTcpSocket::readyRead, this, &SocketExample::onReadyRead, Qt::ConnectionType::DirectConnection); connect(&clientSocket, &QTcpSocket::disconnected, this, &SocketExample::onDisconnected, Qt::ConnectionType::DirectConnection); } SocketExample::~SocketExample() { aboutToClose = true; if (timerId) { killTimer(timerId); timerId = 0; } clientSocket.abort(); } SocketExample::Initialize() { clientBound = clientSocket.bind("172.26.28.1") if (!clientBound) return false; timerId = startTimer(std::chrono::milliseconds(20000), Qt::TimerType::VeryCoarseTimer); if (!timerId) return false; return true; } /*override*/ void SocketExample::timerEvent(QTimerEvent *) { switch (clientSocket.state()) { case QTcpSocket::SocketState::UnconnectedState: case QTcpSocket::SocketState::BoundState: clientSocket.connectToHost(QHostAddress("172.26.20.30"), QIODevice::OpenMode::ReadWrite); break; default: break; } } /*slots*/ void SocketExample::onErrorOccurred(QTcpSocket::SocketError socketError) { switch (socketError) { case QTcpSocket::SocketError::ConnectionRefusedError: break; default: clientSocket.abort(); break; } } void SocketExample::onStateChanged(QTcpSocket::SocketState socketState) { // print string representation of *socketState* } void SocketExample::onConnected() { // omitted details } void SocketExample::onReadyRead() { // omitted details } void SocketExample::onDisconnected() { clientBound = false; if (!aboutToClose) QTimer(0, this, &SocketExample::bindSocket); } void SocketExample::bindSocket() { if (clientSocket.localAddress() == QHostAddress("172.26.28.1")) { clientBound = true; if (timerId) return; timerId = startTimer(std::chrono::milliseconds(20000), Qt::TimerType::VeryCoarseTimer); if (!timerId) { // print about failed timer return; } } else { clientBound = clientSocket.bind(QHostAddress("172.26.28.1")); if (!clientBound) { if (timerId) { killTimer(timerId); timerId = 0; } // print about failed bind return; } if (timerId) return; timerId = startTimer(std::chrono::milliseconds(20000), Qt::TimerType::VeryCoarseTimer); if (!timerId) { // print about failed timer return; } } } Now it looks a bit cleaner and the main difference here is the slot SocketExample::bindSocket which tries its best to bind a socket to a given address and start a reconnection timer. Just to recap the original post: I want to connect to a server in another network which runs a QTcpServer. Both the server and my program (i.e. the client) are written with Qt 5.15.8 and run on Debian 12. Sometimes the network is unaccessible which leads to rejection of connection attempts, I simulate this behaviour with nftables and rejected rule as follows: nft add table ip filter nft add chain ip filter output { type filter hook output priority 0 \; } nft add rule ip filter output ip daddr 172.26.20.30 reject I simulate this behaviour because for some reason when a connection attempt gets rejected the socket starts to spam connect and poll system calls hunders of times per second. This was the original post. The problem stays the same: rejected connection attempts are causing CPU usage spike because connect and poll system calls are called hunders of times per second. And they start, happen and end between my QTcpSocket::connectToHost call and SocketExample::onErrorOccurred slot fires for the very first time. So I can't catch this hapenning, since control flow returns to my code after spamming has already ended. Now to new details: I have built libQt5Network.so.5.15.8 with debugging symbols and extended debugging messages in the code. Here's what I got: we follow the standard debug messages of the network module code and getting messages about the socket changed state 14:14:01 [D] QAbstractSocket::connectToHost([172.26.20.30], 8406, 3)... 14:14:01 [D] QAbstractSocket::connectToHost("172.26.20.30", 8406, 3)... 14:14:01 [D] QTcpSocket::SocketState::HostLookupState 14:14:01 [D] QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &) at qabstractsocket.cpp:1015 14:14:01 [D] QAbstractSocketPrivate::_q_startConnecting(hostInfo == {172.26.20.30}) 14:14:01 [D] QTcpSocket::SocketState::ConnectingState 14:14:01 [D] QAbstractSocketPrivate::_q_connectToNextAddress() at qabstractsocket.cpp:1087 14:14:01 [D] QAbstractSocketPrivate::_q_connectToNextAddress(), connecting to 172.26.20.30:8406, 1 left to try 14:14:01 [D] QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 port) at qnativesocketengine.cpp:597 14:14:01 [D] address==172.26.20.30 14:14:01 [D] port==8406 14:14:01 [D] QNativeSocketEnginePrivate::nativeConnect() 10 14:14:01 [D] connectResult==-1 (return value of ::connect) 14:14:01 [D] errno==115 (Operation now in progress) then we can see how the internal socket state changes from BoundState to ConnectingState 14:14:01 [D] QAbstractSocketEnginePrivate::socketState==4 (before switch) 14:14:01 [D] QAbstractSocketEnginePrivate::socketState==2 (after switch) 14:14:01 [D] QNativeSocketEnginePrivate::nativeConnect(172.26.20.30, 8406) == false (Connection in progress) 14:14:01 [D] QAbstractSocket::connectToHost("172.26.20.30", 8406) == false (connection in progress) And here I found something new: as soon as first connection attempt ends the internal notifier gets a connection notification from QCoreApplication::notifyInternal2 which through several jumps calls connect system call: #0 QNativeSocketEnginePrivate::nativeConnect (this=this@entry=0x5650efa17f10, addr=..., port=port@entry=8406) at socket/qnativesocketengine_unix.cpp:457 #1 0x00007f2f4fb4655e in QNativeSocketEngine::connectToHost (this=0x5650efa00ae0, address=..., port=<optimized out>) at socket/qnativesocketengine.cpp:617 #2 0x00007f2f4fb466bc in QNativeSocketEngine::connectionNotification (this=0x5650efa00ae0) at socket/qnativesocketengine.cpp:639 #3 0x00007f2f4fb47910 in QWriteNotifier::event (this=0x5650efaad4c0, e=0x7ffedc03ac80) at socket/qnativesocketengine.cpp:1330 #4 0x00007f2f4e6b16cd in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5 #5 0x00007f2f4e70a38d in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5 14:14:01 [D] QWriteNotifier::event(QEvent *e) at qnativesocketengine.cpp:1303 14:14:01 [D] e->type()==50 14:14:01 [D] engine->connectionNotification() 14:14:01 [D] QNativeSocketEngine::connectionNotification() at qnativesocketengine.cpp:621 14:14:01 [D] QAbstractSocketEngine::state()==2 14:14:01 [D] QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 port) at qnativesocketengine.cpp:597 14:14:01 [D] address==172.26.20.30 14:14:01 [D] port==8406 14:14:01 [D] QNativeSocketEnginePrivate::nativeConnect() 10 14:14:01 [D] connectResult==-1 (return value of ::connect) 14:14:01 [D] errno==114 (Operation already in progress) 14:14:01 [D] QAbstractSocketEnginePrivate::socketState==2 (before switch) 14:14:01 [D] QAbstractSocketEnginePrivate::socketState==2 (after switch) 14:14:01 [D] QNativeSocketEnginePrivate::nativeConnect(172.26.20.30, 8406) == false (Connection in progress) 14:14:01 [D] QWriteNotifier::event(QEvent *e) at qnativesocketengine.cpp:1303 14:14:01 [D] e->type()==50 14:14:01 [D] engine->connectionNotification() 14:14:01 [D] QNativeSocketEngine::connectionNotification() at qnativesocketengine.cpp:621 So this notification being sent hundreds of times per second is causing at least connect system call spam, I'm still not sure what spams poll system call though. Connection notifications are sent many times when finally some internal timer fires and one of connect calls returns ECONNREFUSED which in the end changes the socket state to UnconnectedState and ends the spamming: 14:14:02 [D] QWriteNotifier::event(QEvent *e) at qnativesocketengine.cpp:1303 14:14:02 [D] e->type()==50 14:14:02 [D] engine->connectionNotification() 14:14:02 [D] QNativeSocketEngine::connectionNotification() at qnativesocketengine.cpp:621 14:14:02 [D] QAbstractSocketEngine::state()==2 14:14:02 [D] QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 port) at qnativesocketengine.cpp:597 14:14:02 [D] address==172.26.20.30 14:14:02 [D] port==8406 14:14:02 [D] QNativeSocketEnginePrivate::nativeConnect() 10 14:14:02 [D] connectResult==-1 (return value of ::connect) 14:14:02 [D] errno==111 (Connection refused) 14:14:02 [D] QAbstractSocketEnginePrivate::socketState==2 (before switch) 14:14:02 [D] QAbstractSocketEnginePrivate::socketState==0 (after switch) 14:14:02 [D] QNativeSocketEnginePrivate::nativeConnect(172.26.20.30, 8406) == false (Connection refused) 14:14:02 [D] QAbstractSocketPrivate::connectionNotification() at qabstractsocket.cpp:822 14:14:02 [D] QAbstractSocketPrivate::state==2 14:14:02 [D] QAbstractSocketPrivate::connectionNotification() testing connection 14:14:02 [D] QAbstractSocketPrivate::_q_testConnection() at qabstractsocket.cpp:1187 14:14:02 [D] QAbstractSocketPrivate::_q_testConnection() connection failed, checking for alternative addresses 14:14:03 [D] QAbstractSocketPrivate::_q_connectToNextAddress() at qabstractsocket.cpp:1087 14:14:03 [D] QAbstractSocketPrivate::_q_connectToNextAddress(), all addresses failed. 14:14:03 [D] QTcpSocket::SocketState::UnconnectedState So this is some new details I found, maybe a similar problem has already been discussed somewhere. I would appreciate any input on the topic and new details. Many thanks, Daniel
  • QTabBar-like list of "x-clickable" buttons?

    Unsolved
    10
    0 Votes
    10 Posts
    3k Views
    L
    @Nathaniel said in QTabBar-like list of "x-clickable" buttons?: There's a common pattern in web UIs where they show a list of items via "buttons" (more precisely, "labels" in the Qt sense because the widget as a whole is not clickable) with a small, clickable "x" in the top-left corner. Clicking on the "x" removes the label from the list. The label is usually in a flat-button style with a thin border. In Qt, one might add labels to the list by choosing from a QComboBox. As far as I know, Qt has no native buttons/labels with this kind of functionality. However, it is similar to how QTabBar works with tabsClosable set to true. So maybe a list of such buttons could be implemented via an ordinary QTabBar and changing the styling. However, this is obviously an atypical use of QTabBar and it might take a lot of work to get the style right so it doesn't confuse the user; there's no QStackWidget being controlled by the tab bar. Is there a 3rd party library that might have such as QLabel subclass implemented already? I’d look for an existing Qt chip or tag widget with a close button, or use a custom widget if no suitable library is available.
  • 2 Votes
    3 Posts
    10k Views
    M
    indexing by Google worked. :-) In a µC emulation project, where i want to change the emulated program as little as possible, i 'secretly' start a c++ thread on which i create and run the QApplication, but it fails with the "not the main thread" message. With the insight from your article i realized that creating two static QObjects during static initialization phase caused the problem. Replaced them with pointers, and: bingo, it worked. Thanks a lot for this article!
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    6 Views
    No one has replied
  • Lifetime of QByteArray references when constructing QRawFont using loadFromData()

    Solved
    5
    0 Votes
    5 Posts
    271 Views
    P
    If the font engine is destroyed when the QRawFont is, and the font engine isn't shared between different fonts, then it should be fine. And unfortunately for me, I don't know what fonts or how many fonts might be loaded, so I want to prevent two copies of the font data existing at once. Thanks for the help though!
  • Debug build (CMAKE) on Linux failing

    Solved
    4
    0 Votes
    4 Posts
    232 Views
    ansifpiA
    Glad that fixed it. CMake’s Modules tree can end up half-installed sometimes (upgrade/path mix-up). Once CMakeCXXCompilerABI.cpp is back, AutoMoc is happy again. Good luck with DeepSkyStacker.
  • QDialog minimize and maximize buttons on Wayland

    Solved
    8
    0 Votes
    8 Posts
    605 Views
    SGaistS
    @SiFox Thank you ! :-)
  • What kinds of desktop applications are developers making internationally in 2026?

    Unsolved
    3
    0 Votes
    3 Posts
    282 Views
    SGaistS
    @SimonSchroeder depending on your needs the new Qt Canvas Painter might be interest.
  • Looking for Qt commercial licensing sales contact in China (Application Development)

    Solved
    5
    0 Votes
    5 Posts
    524 Views
    T
    Your best bet is opening a sales ticket directly inside account.qt.io while your evaluation is running. That immediately pings a rep in their CRM, so they usually get back to you way faster than waiting on email. Also, if you're dealing with company procurement and need a local fapiao, going through a local software distributor in China is often way less headache than buying directly from Qt HQ. Calling the Shanghai office directly during regular work hours usually works too if you don't mind following up by phone.
  • QFontDialog on macOS 27 isn't modal anymore

    Unsolved
    7
    1 Votes
    7 Posts
    2k Views
    T
    Classic macOS breaking platform consistency again. We ran into the exact same issue after updating our build machines — calling the static QFontDialog::getFont basically turns into a dead end because the native panel now behaves more like an inspector rather than a traditional modal dialog. Setting the QFontDialog::DontUseNativeDialog flag is pretty much the only sane workaround right now if you rely on blocking modal flow with OK/Cancel, even though the Qt-rendered dialog looks noticeably out of place on newer macOS versions.
  • QTextBrowser.setHTML do not support <input type=checkbox>

    Solved
    3
    0 Votes
    3 Posts
    258 Views
    sonichyS
    It is nice!
  • How to replace - [X] *

    Solved
    3
    0 Votes
    3 Posts
    247 Views
    sonichyS
    Way 1 is more easy.