Skip to content

General and Desktop

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

    Pinned Locked
    29
    3 Votes
    29 Posts
    28k 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.

  • 0 Votes
    1 Posts
    4 Views
    No one has replied
  • A problem with QWidget update

    Unsolved
    8
    0 Votes
    8 Posts
    192 Views
    A

    @ChrisW67 Since this is just a simplified example, I just want to explain to that bro how one QObject works in two threads. The reason for the two threads is that I would post-process the image after receiving it from the camera's SDK and then pass it to the main thread to paint with paintEvent

  • 0 Votes
    3 Posts
    36 Views
    T
    Environment

    Qt: v6.8.1 (mingw_64)
    Windows 11

    Minimal Example Problem

    When the program is running, toggle "Underline keyboard short cuts and keys" in "Control Panel\Ease of Access\Ease of Access Center\Make the keyboard easier to use". The label doesn't update the underline, until the program is exited and restarted. QMenu can update this without restarting the program. Probably QLabel doesn't have a slot to update display when this system setting changes.
    a7032481-d29c-4456-83cc-e09d169cf0a2-image.png

    Code

    My code is recognized as spam and prohibited from posting here. I'll attach download link.
    https://drive.google.com/file/d/18V_E4UvpG2e9h9MDhHR_YLOanw9t_leJ/view?usp=sharing
    The key part is

    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { lineEdit1 = new QLineEdit; lineEdit2 = new QLineEdit; // bug: QLabel underline for accelerator doesn't update when Alt is pressed in Windows label1 = new QLabel(tr("Field &A:")); label1->setBuddy(lineEdit1); label2 = new QLabel(tr("Field &B:")); label2->setBuddy(lineEdit2); QWidget *centralWidget = new QWidget; setCentralWidget(centralWidget); QGridLayout *mainLayout = new QGridLayout(centralWidget); mainLayout->addWidget(label1, 0, 0); mainLayout->addWidget(lineEdit1, 0, 1); mainLayout->addWidget(label2, 1, 0); mainLayout->addWidget(lineEdit2, 1, 1); menuBar()->addMenu(tr("&Menu")); }
  • 0 Votes
    7 Posts
    48 Views
    Christian EhrlicherC

    Install the Qt debug libs and source code and step into the Qt source code

  • 0 Votes
    1 Posts
    8 Views
    No one has replied
  • 0 Votes
    6 Posts
    77 Views
    SGaistS

    Good, in that case, please mark the thread as solved using the topic tools button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)

  • What do you use for mac/win in-app-purchase?

    Unsolved
    5
    0 Votes
    5 Posts
    77 Views
    SGaistS

    Currently I am not but I think there was an answer on the development mailing.

  • QMenu infrastructure - is deriving an own Menu not an option?

    Unsolved
    15
    1 Votes
    15 Posts
    384 Views
    SGaistS

    @St0fF you should check the openings on the Qt Group website.

  • Qt6 and Windows 2016

    Unsolved
    2
    0 Votes
    2 Posts
    23 Views
    Axel SpoerlA

    Confirm. See here.
    https://doc.qt.io/qt-6/supported-platforms.html

  • Convert function to qt notation

    Solved
    4
    0 Votes
    4 Posts
    48 Views
    GaoboG

    Maybe you can ask chatgpt.....
    This answer is from deepseek:

    To convert the JavaScript function int64LE to Qt, you need to create a QByteArray that holds the little-endian byte representation of a 64-bit signed integer. Here's the step-by-step solution:

    Resize the QByteArray to hold 8 bytes (64 bits). Cast the input quint64 number to qint64 to handle it as a signed integer. Extract each byte in little-endian order by masking and shifting the value. Store each byte in the QByteArray. QByteArray UtilsEssp::int64LE(quint64 number) { QByteArray buffer; buffer.resize(8); // Allocate 8 bytes qint64 value = static_cast<qint64>(number); // Treat as signed // Extract each byte in little-endian order for (int i = 0; i < 8; ++i) { buffer[i] = static_cast<char>(value & 0xFF); value >>= 8; } return buffer; }

    Explanation:

    Resizing the Buffer: buffer.resize(8) ensures the QByteArray has space for 8 bytes. Casting to Signed: static_cast<qint64>(number) converts the unsigned input to a signed 64-bit integer, preserving the bit pattern. Little-Endian Extraction: The loop iterates 8 times, each time taking the least significant byte using value & 0xFF, then right-shifting value by 8 bits. This fills the QByteArray from the least significant byte to the most significant, achieving little-endian order.

    This approach mirrors the original JavaScript functionality by directly manipulating the byte representation, ensuring compatibility with systems expecting a signed 64-bit integer in little-endian format.

  • Question about Qhttpserver and QtFuture

    Unsolved
    4
    0 Votes
    4 Posts
    183 Views
    SGaistS

    This article shows a way to do it.

  • 0 Votes
    12 Posts
    147 Views
    J

    At the moment, the suggested code in https://www.kdab.com/single-shot-connections/ seems to work perfectly so far:

    auto connection = std::make_unique<QMetaObject::Connection>(); auto connectionPtr = connection.get(); auto singleShot = [receiver, connection = std::move(connection)](parameters) { QObject::disconnect(*connection); receiver->slot(parameters); }; *connectionPtr = connect(sender, &Sender::signal, receiver, std::move(singleShot)));
  • How to use ODB with QT

    Unsolved
    5
    0 Votes
    5 Posts
    117 Views
    A

    Ok, the program I inherited uses the QSqlDatabase::addDatabase to connect. However when interacting with the database, code like the following is used:

    QList<QString> Ps; QString selectQuery = QString( "SELECT DISTINCT column.name " "FROM table " "WHERE col = :value" ); QSqlQuery query; query.prepare(selectQuery); query.bindValue(":value", value); if (query.exec()) { while (query.next()) { QString P; P = query.value("Properties.name").toString(); Ps.append(P); } }

    My understanding is that ODB and other ORMs would allow me to instead write something more like:

    using table_query = ODBquery<table>; for (QString& P: db.query<P> (table_query::value ="value);
  • Complete novice, where do I begin with a HMI project

    Unsolved
    2
    0 Votes
    2 Posts
    60 Views
    Pl45m4P

    Hi and welcome to the forum,

    @Groundbounce said in Complete novice, where do I begin with a HMI project:

    I'm looking at using Qt and in the process will learn C++, I currently use C on micro controllers.

    make yourself familiar with OOP/C++ first. C and C++ is similar but there might be some traps to fall for.

    This would be HMI that displays auto style gauges as the visual output.
    [...]
    From what I can tell I need to use a Qt quick project.

    Yes, for these kind of things QtQuick / QMLanguage is more suitable than a QtWidgets Application.
    Edit: [Then your lack of C++ experience doesn't matter too much, since QML is a whole different language (inspired by JavaScript and JSON-style format)]

    I am not sure if I should be setting up the graphics in designer or creator.

    In general both ways are possible, but QtDesigner (the standalone as well as the QtCreator integrated one) can't do QtQuick.
    For more advanced QtQuick Designs there is Qt Design Studio (here), which also features templates for gauge-like elements, animations and more.

  • Errors [unknown type name 'import'], etc.

    Solved
    9
    0 Votes
    9 Posts
    167 Views
    F

    Thank you all for your precise and relevant answers.
    Best regards.

  • Update rect in delegate when changing content's size

    Solved
    9
    1 Votes
    9 Posts
    110 Views
    JonBJ

    @Mark81
    Yes, I think whatever displayText() returns as text (default without your specific number of decimal places) is "measured" by Qt for sizeHint(), and is simpler for your case than paint(). The latter would be required if you wanted to affect other aspects of the output than only the text, e.g. you were drawing a box round it. But if the text is all you want to alter I would use displayText().

  • Error 'isRelocatable': undeclared identifier.

    Unsolved
    11
    0 Votes
    11 Posts
    431 Views
    jsulmJ

    @wasimIM I don't have a solution. Maybe try with more recent MS compiler if there is a newer version?

  • Encrytp and Decrypt function in JS to Qt

    Solved
    3
    0 Votes
    3 Posts
    60 Views
    D

    @jsulm looks good.

    QByteArray crypt(QByteArray key, QByteArray message) { QAESEncryption encryption(QAESEncryption::AES_128, QAESEncryption::ECB); return encryption.encode(message, key); } QByteArray decrypt(QByteArray key, QByteArray data) { QAESEncryption encryption(QAESEncryption::AES_128, QAESEncryption::ECB); return encryption.decode(data, key); }
  • QThread used to call function pointer

    Solved
    6
    0 Votes
    6 Posts
    108 Views
    P

    Hi @jsulm,

    I updated the main function to initialize the EventLoop it is working as expected.

    Thank you very much for your help,
    Pierre-Emmanuel de Robien