Skip to content

General and Desktop

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

    Pinned Locked
    29
    2 Votes
    29 Posts
    26k 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
    10 Views
    No one has replied
  • 0 Votes
    2 Posts
    13 Views
    A

    Hi

    please prefer posting your code as text rather than screenshot.

    Your questions are a little unclear to me, but if I understand it right, at least for the two first

    yes you can safely delete an object from within it's parent or from any other object, however, if you ever want an object to delete itself, I would rather suggest doing this->deletelater() ; no the deleter is not deleted please reformulate correctly
  • Correct way to proxy SQLite tables

    Unsolved
    2
    0 Votes
    2 Posts
    22 Views
    S

    Its possible to sort second table by id and then convert it into tree

  • Fetch text from a site as QString

    Solved
    23
    0 Votes
    23 Posts
    507 Views
    R

    @Pl45m4 Functions ( downloadFile and replyFinished) are not in the header. I did not specify that but I did add MyClass scope e.g. void MyClass::downloadFile().

    @SGaist So:

    MyClass(QObject *parent = nullptr) : QAbstractListModel(parent), m_manager(new QNetworkAccessManager(this)) { connect(m_manager, &QNetworkAccessManager::finished, this, &MyClass::downloadFinished); }
  • 0 Votes
    6 Posts
    33 Views
    K

    Found the answer in https://forum.qt.io/topic/70575/qt-charts-crash
    In main.cpp you should change QGuiApplication to QApplication
    QApplication app(argc, argv);

  • 0 Votes
    20 Posts
    375 Views
    AndyBriceA

    Thanks, Simon.

  • Some quick feedback on the 6.8 implementation of QT/Protobuf

    Unsolved
    4
    0 Votes
    4 Posts
    87 Views
    semlanikS

    Here are two bugs for the context:
    https://bugreports.qt.io/browse/QTBUG-119912
    https://bugreports.qt.io/browse/QTBUG-119913

    And the change that removed them:
    https://codereview.qt-project.org/c/qt/qtgrpc/+/585992

    P.S. The fact you complain about the removal, forces us to reconsider our decision.

  • Managing events of a QScxmlStateMachine

    Unsolved
    6
    0 Votes
    6 Posts
    102 Views
    jsulmJ

    @Max said in Managing events of a QScxmlStateMachine:

    If the machine is in a particular state, I modify the style of another widget before the hand is sent back to the user

    In an event driven application you would react on state machine change instead of posting an event and expecting it to take effect immediately. You should rethink your design.

  • 0 Votes
    6 Posts
    74 Views
    H

    After some digging through the source code of QAbstractOAuth to see which classes are used under the hood I managed to do it this way:

    std:: string json = CalendarJsonParser::writeEventQuery(event); // the Request Body - yes, I'm using the jsoncpp library instead of QJsonObject, for some reason QVariantMap parameters; parameters["calendarId"] = QString::fromStdString(calendar_list[calendarIdx].id); //the Parameters QString urlStr = "https://www.googleapis.com/calendar/v3/calendars/calendarId/events"; QUrl url = QUrl(urlStr); QUrlQuery query; //the query should store the parameters //adding the parameters to the query for (auto it = parameters.begin(), end = parameters.end(); it != end; ++it){ query.addQueryItem(it.key(), it.value().toString()); } //adding the query to the url: url.setQuery(query); //creating request from the url QNetworkRequest req(url); QByteArray verb = "POST"; //POST, PUT, use whatever the API defines //google is my QOAuth2AuthorizationCodeFlow object, so I'm adding the additional token stuff here google->prepareRequest(&req, verb, json.data()); //getting the reply pointer: auto reply = google->networkAccessManager()->sendCustomRequest(req, verb, json.data()); //doing something with the reply connect(reply, &QNetworkReply::finished, this, [=]() { /*implement handling here*/ });
  • Problems migrating from 5.14.2 tp Qt 6.8.0

    Unsolved
    10
    0 Votes
    10 Posts
    79 Views
    Christian EhrlicherC

    @linuxkid said in Problems migrating from 5.14.2 tp Qt 6.8.0:

    Launching the debugger does tell me:

    And now learn how to use a debugger and look into the stack trace from where it is coming.

    "If the QT_FATAL_WARNINGS environment variable is set, qWarning() exits after printing the warning message. This makes it easy to obtain a backtrace in the debugger."

    Not that all is properly written down in the documentation...

  • 0 Votes
    4 Posts
    48 Views
    Christian EhrlicherC

    I tried with MySQL Server 8.3 client libs + MySQL 8.3 Server, MySQL 8.3 Client libs + MariaDB 10.11 Server, MariaDB C Connector 3.3.2 client libs + MySQL 8.3 Server and MariaDB C Connector 3.3.2 and MariaDB 10.11 Server and all works as expected. I only modifed your example to not create a db in the first place and therefore also don't call db.close() with an open query (which is really a strange usecase and I'm not sure we support it but I guess it's only for the testcase):

    int main(int argc, char* argv[]) { QCoreApplication a(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("192.168.178.64"); db.setUserName("testuser"); db.setPassword("testuser"); db.setDatabaseName("testdb"); if (!db.open()) { qDebug() << "Failed to open database : " << db.lastError(); return 0; } QSqlQuery query(db); query.exec("DROP TABLE `org_data_class`"); query.prepare("CREATE TABLE `org_data_class` (" "`index` int(11) NOT NULL AUTO_INCREMENT," "`equip` varchar(50) NOT NULL," "`command` varchar(50) NOT NULL," "PRIMARY KEY (`index`) USING BTREE" ")DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;"); if (!query.exec()) { qDebug() << "Failed to create table : " << query.lastError(); return 0; } query.prepare("INSERT INTO `org_data_class` (`equip`, `command`) VALUES" "('AAA', 'CMD1'), ('BBB', 'CMD2'), ('CCC', 'CMD3');"); if (!query.exec()) { qDebug() << "Failed to insert data : " << query.lastError(); return 0; } QSqlQuery q("SELECT * FROM org_data_class"); while (q.next()) { qDebug() << db.lastError(); qDebug() << q.isValid() << q.isActive() << q.lastError(); qDebug() << q.value(0) << q.value(1) << q.value(2); } return 0; }

    If this testcase does not work for you the only way I see is to try to backport all changes to the Qt mysql plugin to see if this helps somehow (but I can't remember of such a change tbh) or debug by yourself what's going wrong.

  • 0 Votes
    2 Posts
    27 Views
    Pl45m4P

    @ForeverNoob said in QTreeWidget.itemAt returns wrong item in dropEvent:

    Why is that?

    It can only be for one reason:

    event.position().x(), event.position().y()

    these coords are not what you would expect.

    The documentation says:

    item at the coordinates (x, y). The coordinates are relative to the tree widget's viewport().

    So compare that with the position of your correct item

  • 0 Votes
    11 Posts
    168 Views
    Christian EhrlicherC

    @Pl45m4 said in How to stop a checkable button from automatically rendering differently when checked?:

    You could check the source code of QAbstractButton / QToolButton yourself and see how it's done

    Better the style he's using to see what triggers the darkening. Otoh when the style does this I don't understand why a QToolButton should behave differently only for his application.

  • WebSocket with QtWebAssembly

    Unsolved
    3
    1 Votes
    3 Posts
    475 Views
    F

    I found, that connecting from a webassembly websocket client to a wss server works with the sshechoclient and sshechoserver example programs by doing a little modification to the sshechocilent program: delete or comment out the parts which relate to security:

    // Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "sslechoclient.h" #include <QtCore/QCoreApplication> #include <QtCore/QDebug> #include <QtCore/QFile> #include <QtWebSockets/QWebSocket> QT_USE_NAMESPACE //! [constructor] SslEchoClient::SslEchoClient(const QUrl &url, QObject *parent) : QObject(parent) { connect(&m_webSocket, &QWebSocket::connected, this, &SslEchoClient::onConnected); // connect(&m_webSocket, QOverload<const QList<QSslError>&>::of(&QWebSocket::sslErrors), // this, &SslEchoClient::onSslErrors); // QSslConfiguration sslConfiguration; // QFile certFile(QStringLiteral(":/localhost.cert")); // certFile.open(QIODevice::ReadOnly); // QSslCertificate certificate(&certFile, QSsl::Pem); // certFile.close(); // sslConfiguration.addCaCertificate(certificate); // m_webSocket.setSslConfiguration(sslConfiguration); m_webSocket.open(QUrl(url)); } //! [constructor] //! [onConnected] void SslEchoClient::onConnected() { qDebug() << "WebSocket connected"; connect(&m_webSocket, &QWebSocket::textMessageReceived, this, &SslEchoClient::onTextMessageReceived); m_webSocket.sendTextMessage(QStringLiteral("Hello, world!")); } //! [onConnected] //! [onTextMessageReceived] void SslEchoClient::onTextMessageReceived(QString message) { qDebug() << "Message received:" << message; qApp->quit(); } // void SslEchoClient::onSslErrors(const QList<QSslError> &errors) // { // qWarning() << "SSL errors:" << errors; // m_webSocket.ignoreSslErrors(); //qApp->quit(); // } //! [onTextMessageReceived]

    Important!: If the wss server is running on localhost with fake certs, then in Edge browser, client connecting to the server will work, but not in other browsers. But if your wss server has domain name with valid cert (e.g. type of Let's Encrypt), then it will work in major browsers (Chrome, Edge, Firefox) (I tested, it works). Also, host your client application through https connection, e.g. with qtwasmserver.

  • 0 Votes
    4 Posts
    608 Views
    A

    After some debugging it seems to be a bug fixed in Qt 6.4. (and backported in 6.2/6.3)
    According to the old code, QWebSocketPrivate::processData used to be connected using Qt::QueuedConnection, so it may be called after QWebSocketPrivate::processStateChanged. This means the close frame can be unprocessed, leaving closedCode in 1000.
    The commit fixing this is e1c92b57.

  • Is there any conflict between QtQuick folder duplicates?

    Unsolved
    9
    0 Votes
    9 Posts
    83 Views
    D

    @jsulm said in Is there any conflict between QtQuick folder duplicates?:

    It's your application, right?

    Yes, right.

    @jsulm said in Is there any conflict between QtQuick folder duplicates?:

    Why should there be a duplicate in your application on user PC?

    It's unimportant, this has already fixed. But I need some safe way to load QtQuick from qml folder even if there is a duplicate in the root.

    @jsulm said in Is there any conflict between QtQuick folder duplicates?:

    How do you deploy your app?

    By installer.

  • Why macOS app requests exactly 5.dylib libraries?

    Unsolved
    6
    0 Votes
    6 Posts
    125 Views
    SGaistS

    There's a whole article on the subject in Apple's documentation under Dynamic Library Design Guidelines.

  • 0 Votes
    4 Posts
    43 Views
    gfxxG

    real sorry .... see these morning "enum QFont::weight" .... so understand.

    thanks to all

  • QSqlQuery Postgres and timestamp => QDateTime(Invalid)

    Solved
    6
    0 Votes
    6 Posts
    102 Views
    H

    I filed a bug report and it seems that the bug is identified and solved.
    Mni tnx,

    BR Henning