Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.2k Topics 455.1k Posts
  • Reporting inappropriate content on the forums

    Pinned Locked spam
    29
    3 Votes
    29 Posts
    30k 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.
  • [Unit Test Coverage] How can the industry improve QT code coverage

    Unsolved
    8
    0 Votes
    8 Posts
    152 Views
    S
    Best strategy is to design your application from the get go to be testable. When designing Every class, every module, every component you should think "how do I make this testable". The good news when you make things "testable" you also get other "abilities" for free since highly testable components are also a) independent and decoupled b) have high cohesion and simple dependencies c) reusable d) have a coherent API c) have better thought out errors and bug conditions, invariants and pre/post conditions. Then you test your components using whatever (unit) testing framework you like. For UI testing you can also use some UI testing tools such as cucumber or other similar tools
  • 0 Votes
    3 Posts
    48 Views
    V
    Please try to call 'setMask' to round borders in 'resizeEvent' and 'changeEvent -> QEvent::WindowStateChange event' too.
  • 0 Votes
    4 Posts
    29 Views
    jsulmJ
    @mvsri said in Qt Mysql [Mysql Server has gone away] and Silent failures after query exec(): Apart from that, do you find any issues with the code shared above? I'm just wondering why you're spawning a thread everytime AuditLogger::log? QtConcurrent::run uses a thread pool, but I still would use a different approach: let a log thread run as long as the application runs and send log messages to it via signals/slots or invokeMethod. It is also better to use QSqlError::type() instead of searching for a string in the error message (which could change in later Qt versions). You probably get QSqlError::ConnectionError if the connection disappeared.
  • Using file association on macOS

    Solved
    3
    0 Votes
    3 Posts
    26 Views
    PerdrixP
    Thank you lots David
  • InnoSetup / Windows Restart Manager / Native Event Filter problem.

    10
    0 Votes
    10 Posts
    5k Views
    A
    @Sikander-Rafiq said in InnoSetup / Windows Restart Manager / Native Event Filter problem.: @SGaist I have created another thread mentioning QT versions and all code stuff. You can find this thread here https://forum.qt.io/topic/162123/unable-to-launch-qt-desktop-app-from-qt-service-tubidy-using-qprocess Thanks for sharing the link. I happen to have the same issues, I’ll check it out, launching a Qt desktop app from a service using QProcess sounds tricky, especially with display/session permissions. Curious to see what you’ve tried so far..
  • Crashes on macOS ARM using Sockets

    Unsolved
    3
    0 Votes
    3 Posts
    153 Views
    N
    Did you ever find a solution? I'm having the same problem.
  • Qt Styling QTreeWidget : Remove Focus on Icons

    Solved
    7
    0 Votes
    7 Posts
    135 Views
    T
    Hello, I tried a bit and I found the solution class NoTintIconDelegate : public QStyledItemDelegate { public: explicit NoTintIconDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {} void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override { QStyleOptionViewItem opt = option; initStyleOption(&opt, index); // Prepare the painter painter->save(); // Draw the background and selection if (opt.state & QStyle::State_Selected) { painter->fillRect(opt.rect, QColor("#4d78cc")); painter->setPen(opt.palette.highlightedText().color()); } else { painter->fillRect(opt.rect, QColor("#21252b")); painter->setPen(opt.palette.text().color()); } // Draw the text QString text = index.data(Qt::DisplayRole).toString(); QRect textRect = opt.rect.adjusted(20, 0, 0, 0); // Adjust for icon space painter->drawText(textRect, Qt::AlignVCenter | Qt::TextSingleLine, text); // Draw the icon manually without tinting QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)); if (!icon.isNull()) { QPixmap pixmap = icon.pixmap(opt.decorationSize); painter->drawPixmap(opt.rect.left() + 2, opt.rect.top() + (opt.rect.height() - opt.decorationSize.height()) / 2, pixmap); } painter->restore(); } QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override { QSize size = QStyledItemDelegate::sizeHint(option, index); size.setWidth(size.width() + 20); // Add space for icon return size; } }; and then : treeView->setItemDelegate(new NoTintIconDelegate(this)); Have a nice day !
  • App crashed when deployed on another PC

    Unsolved
    8
    0 Votes
    8 Posts
    113 Views
    V
    I reinstalled Qt and opencv on my PC 2, debugged my code, it turns out that a file was not correctly loaded so the app crashed.
  • Using QNetworkAccessManager to download a big file.

    Unsolved
    8
    0 Votes
    8 Posts
    239 Views
    piervalliP
    Yes First row of the standard http Is Protocol URL version\r\n So we can have only 2 space It Is nice protocol simple but powerfull.
  • Qt6 Multimedia Streaming

    Unsolved
    7
    0 Votes
    7 Posts
    87 Views
    Ronel_qtmasterR
    @Molecular4943 you can try Opencv. With opencv you will have control over the frames. I use it to stream cameras url.I think it also support rstp
  • What to do if I can't make a call to `beginInsertRows()` before data is changed?

    Unsolved
    5
    0 Votes
    5 Posts
    75 Views
    KH-219DesignK
    @peter.thompson You may be able to leverage the following fact into a workaround for your situation. I can state from experience that calling these one after the other ("on the same line", as it were) will trigger the signal you probably want/need to have emitted from the (I believe it is modelUpdated, but don't quote me 😉) beginResetModel(); endResetModel(); (of course they don't literally need to be on one line. I'm just emphasizing that you can call them back-to-back, without having changes to the data happen in between, and the result will be that the model "updates" at this time, as far as other watcher objects are concerned) beginResetModel(); endResetModel(); ... is also fine. I have done this in several applications, and at the time I also looked inside the Qt source code to convince myself that it indeed does do what I intend. My use case was not the case that you describe. Rather, I simply had a "complex", many-nested-if-statement logic for selecting which rows were updated in any given case, and I didn't want to add more complexity trying to meticulously piece together what arguments to pass to dataChanged, so I found I could just do this "hack" at the appropriate point, to signal to the relevant QML to repaint "the whole model" (the visual UI representation thereof, more accurately).
  • QtSensor Plugin - supporting multiple types

    Unsolved qsensor
    2
    0 Votes
    2 Posts
    31 Views
    SGaistS
    Hi, I am not aware of any but from a quick look at the documentation, you can create one factory that returns different sensors. I think you just have to register each passing the same factory.
  • QMediaPlayer mp3 playback stalled

    Unsolved
    10
    0 Votes
    10 Posts
    157 Views
    JoeCFDJ
    @nova_xo I am not sure either. But be aware that some delay is often needed in the pipeline for state or position change. Good you found the solution. I use raw gstreamer code and can find out where waiting is exactly needed. You may need to guess a bit with Qt.
  • How to debug projects prepared by libtool (autotools) at Qt Creator?

    3
    0 Votes
    3 Posts
    925 Views
    D
    @evorop said in How to debug projects prepared by libtool (autotools) at Qt Creator?: But... How realize "libtool --mode=execute gdb hell" at the Qt Creator for correct debug at visual grafic interface. The same question... I found this topic... But I can't apply bash script with name libtoolgdb #!/bin/bash exec libtool --mode=execute /usr/bin/gdb "$@" [image: b329bf04-5e69-4d30-adc0-a37e19458901.png]
  • Dselect QListWidget item

    Unsolved
    2
    0 Votes
    2 Posts
    46 Views
    Axel SpoerlA
    Ad 1: To recognise a mouse press in an empty area, install an event filter and handle QEvent::MouseButtonPress. Pass the mouse event's point to itemAt() and clear the selection, if it returns nullptr. You can do the same with QEvent::FocusOut, to handle a click outside the list view. Mind that this may not work, in case the list widget is a focus proxy (it isn't by default). Ad 2: The list view is populated programmatically. Just call clearSelection() when this has been done. Ad 3: Read the height after the list widget has been populated. Add the desired height margin and use QWidget::setMinimumHeight().
  • html in qt widget?

    Unsolved
    2
    0 Votes
    2 Posts
    40 Views
    B
    QTextDocument supports HTML4 markup, you can read this: https://doc.qt.io/qt-6/richtext-html-subset.html The simplest way to show html content in Qt Widget would be using QLabel's setText or QTextEdit's setHtml method. If the html code is more complicated than just rich text, or you need some html features that QTextDocument doesn't support, then you can use QWebEngineView in Qt WebEngine module.
  • QProcess signal out of order ?

    Unsolved
    6
    0 Votes
    6 Posts
    99 Views
    D
    Actually, I expected that one more signal would occur if the readyReadStandardOutput was processing while the process finished. The odd thing was there was a second readyReadStandardOutput signal happening. Although I have checked with the guy doing the actual work, and the second one always returns an empty string when readAllStandardOutput is called.
  • PCAN-LAN integration in QTSerialBus

    Unsolved
    3
    0 Votes
    3 Posts
    129 Views
    aha_1980A
    @fcol95 While the use case sounds interesting I currently don't have access to such devices and therefore cannot work on an integration. Regards
  • How to create custom delegate for QComboBox

    Solved
    8
    0 Votes
    8 Posts
    153 Views
    O
    @Pl45m4 Your solution is well suited for my purpose! Thank you!