Skip to content
  • Debug of real time dependent app

    Unsolved General and Desktop real time debug
    6
    0 Votes
    6 Posts
    72 Views
    Z
    @Kent-Dorfman said in Debug of real time dependent app: QTimer isn't going to be accurate at intervals less than the 2*(1/HZ) value of the OS Thank you. It was a surprize for me that neither my Win11 nor Qt can manage intervals I expected to deal with. Let me show you my setup to make my expectations clear for you. It is a pure math/physics simulations that describe launch and further path of propelled projectile. At some points its velocity exceeds 1000 m/s that`s why for precise its state update I need a very short intervals e.g 1/1000 second. And I supposed to make my thread sleep within this interval ))) void SimulationWorker::runSimulation() { double nextStateInterval=0.001; //update of coordinates, velocity, thrust, pitch, yaw double nextEnvInterval=0.005; //update of air density, drag, gravity double nextEstimatorInterval=0.5; //update of predicted impact point //QElapsedTimer m_timer.start(); while(!m_shouldStop){ elapsedTime = m_timer.elapsed()/1000.0; //to seconds pitchManeuverEvent(elapsedTime); //thrust angle adjustment based on current velocity vector and timer if(elapsedTime>=nextStateUpdate){ stateTimeIncrement=elapsedTime-lastStateUpdate; lastStateUpdate=elapsedTime; m_state->updateMissileState(stateTimeIncrement, m_CurrentState, m_thrustVec); //Projectile dynamics calculations: coords, thrust, pitch, azimuth nextStateUpdate=elapsedTime+nextStateInterval; } if(elapsedTime>=nextEnvUpdate){ envTimeIncrement=elapsedTime-lastEnvUpdate; lastEnvUpdate=elapsedTime; m_env->updateEnvironment(m_CurrentState); //environment update drag and atmosphere condition nextEnvUpdate=elapsedTime+nextEnvInterval; } if(elapsedTime>=nextEstimatorUpdate){ m_estimator->updateEstimation(elapsedTime); //impact point predictor nextEstimatorUpdate=elapsedTime+nextEstimatorInterval; } //some other events for guidance //thread goes to sleep if it has time to next event sleepUntilNextEvent(elapsedTime, nextStateUpdate, nextEnvUpdate, nextEstimatorUpdate, nextRecorderUpdate); if(!cutOff){ //mass update and thrust cut off switcher m_CurrentState.currentMass=updateMass(cutOff, elapsedTime); } } So my current approach is impossible, right? I added loop cycle counter and it seems that thread cannot wake up faster than 15 ms loopCounter 1 , time 0 loopCounter 2 , time 0.002 loopCounter 3 , time 0.014 loopCounter 4 , time 0.018 loopCounter 5 , time 0.034 loopCounter 6 , time 0.049 loopCounter 7 , time 0.065 loopCounter 8 , time 0.081
  • Qt Graphs. Building 2d plot using c++ only.

    Unsolved Qt 6
    22
    0 Votes
    22 Posts
    3k Views
    goldenhawkingG
    In response to the above requirements, I have written a small testing program. 10 curves can be refreshed correctly, but colors cannot be set independently, and there are extra connecting lines between the curves. Can someone help me identify where I went wrong? thank! pro file QT += core gui widgets quickwidgets graphs quick CONFIG += c++17 SOURCES += \ main.cpp \ graphstest.cpp HEADERS += \ graphstest.h FORMS += \ graphstest.ui graphstest.h #ifndef GRAPHSTEST_H #define GRAPHSTEST_H #include <QDateTimeAxis> #include <QDialog> #include <QLineSeries> #include <QValueAxis> #include <QVector> QT_BEGIN_NAMESPACE namespace Ui { class graphsTest; } QT_END_NAMESPACE class graphsTest : public QDialog { Q_OBJECT public: graphsTest(QWidget *parent = nullptr); ~graphsTest(); protected: void timerEvent(QTimerEvent *evt) override; private slots: void on_pushButton_ok_clicked(); private: Ui::graphsTest *ui; QDateTimeAxis *m_ax; QValueAxis *m_ay; int m_timerEvent; QVector<QLineSeries *> m_lineSeries; }; #endif // GRAPHSTEST_H graphstest.cpp #include "graphstest.h" #include <QDateTime> #include <QDebug> #include <QQuickItem> #include "ui_graphstest.h" graphsTest::graphsTest(QWidget *parent) : QDialog(parent) , ui(new Ui::graphsTest) , m_ax(new QDateTimeAxis(this)) , m_ay(new QValueAxis(this)) , m_timerEvent(0) { ui->setupUi(this); QDateTime dtmNow = QDateTime::currentDateTime(); m_ax->setMin(dtmNow.addDays(-1)); m_ax->setMax(dtmNow); m_ay->setRange(-100, 100); QList<QObject *> seriesList; ui->graphsView->setResizeMode(QQuickWidget::SizeRootObjectToView); ui->graphsView->setInitialProperties({{"seriesList", QVariant::fromValue(seriesList)}, {"axisX", QVariant::fromValue(m_ax)}, {"axisY", QVariant::fromValue(m_ay)}}); ui->graphsView->loadFromModule("QtGraphs", "GraphsView"); m_timerEvent = startTimer(500); } graphsTest::~graphsTest() { delete ui; } void graphsTest::timerEvent(QTimerEvent *evt) { if (evt->timerId() == m_timerEvent) { QList<QPointF> data; QDateTime dtmNow = QDateTime::currentDateTime(); const int N = m_lineSeries.size(); for (int n = 0; n < N; ++n) { for (int i = 0; i < 30; ++i) { data << QPointF(dtmNow.addSecs(-3600 * 24.0 / 30 * (29 - i)).toMSecsSinceEpoch(), (rand() % 500 - 250) / 100.0 + n * 16 - 80); } m_lineSeries[n]->replace(data); } m_ax->setMin(dtmNow.addDays(-1)); m_ax->setMax(dtmNow); } } void graphsTest::on_pushButton_ok_clicked() { if (m_lineSeries.size() >= 10) return; //Prepare new data QLineSeries *newLine = new QLineSeries(this); newLine->setColor(QColor(rand() % 128, rand() % 128, rand() % 128)); //Add to Graph QVariant seriesListVariant = ui->graphsView->rootObject()->property("seriesList"); if (seriesListVariant.canConvert<QQmlListProperty<QObject>>()) { QQmlListProperty<QObject> prop = seriesListVariant.value<QQmlListProperty<QObject>>(); prop.append(&prop, newLine); m_lineSeries.append(newLine); } } graphstest.ui <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>graphsTest</class> <widget class="QDialog" name="graphsTest"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>579</width> <height>332</height> </rect> </property> <property name="windowTitle"> <string>graphsTest</string> </property> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QQuickWidget" name="graphsView"> <property name="resizeMode"> <enum>QQuickWidget::ResizeMode::SizeRootObjectToView</enum> </property> </widget> </item> <item> <layout class="QVBoxLayout" name="verticalLayout"> <property name="sizeConstraint"> <enum>QLayout::SizeConstraint::SetMaximumSize</enum> </property> <item> <widget class="QPushButton" name="pushButton_ok"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="text"> <string>Add Serials</string> </property> </widget> </item> <item> <spacer name="verticalSpacer"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="orientation"> <enum>Qt::Orientation::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>40</height> </size> </property> </spacer> </item> </layout> </item> </layout> </widget> <customwidgets> <customwidget> <class>QQuickWidget</class> <extends>QWidget</extends> <header location="global">QtQuickWidgets/QQuickWidget</header> </customwidget> </customwidgets> <resources/> <connections/> </ui> main.cpp #include "graphstest.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); graphsTest w; w.show(); return a.exec(); } Qt 6.9.1 Mingw64 in windows 11: [image: b7ce4b6c-16e4-4775-8b16-dec3fe4c06ab.png] Further more, how to add a rubber-band selection tool and connect QML signals to the C++ slots, is a bit hard for me . I'll try it later.
  • QT Design Studio with PySide6

    Unsolved Qt Design Studio
    8
    0 Votes
    8 Posts
    4k Views
    S
    QT Design Studio paired with PySide6 is a powerful combo! Designing UIs visually and then integrating them with Python logic streamlines the workflow for developers and designers alike. Great for rapid prototyping and production apps! https://8171search.pk/
  • QWebEngine with Raspberry pi 5 (using PySide6)

    Unsolved QtWebEngine
    3
    0 Votes
    3 Posts
    28 Views
    M
    @SGaist said in QWebEngine with Raspberry pi 5 (using PySide6): Linux distribution Hi, I'm using a Raspberry Pi, with Debian linux distribution. I installed PySide6 using pip install PySide6 inside a virtual environment.
  • 0 Votes
    2 Posts
    32 Views
    hskoglundH
    Hi, maybe try QWindow's closeEvent and set accepted to false, or on the C++ side the closeEvent()? In C++, say like this: ... void MainWindow::closeEvent(QCloseEvent *event) { static bool bThreadsDone = false; if (!bThreadsDone) { event->ignore(); QTimer::singleShot(1234,[&bThreadsDone] { // check if threads are done (assuming yes :-) bThreadsDone = true; qApp->quit(); }); } ... } When the user quits the app, in the above example, there will be a delay of 1234 milliseconds before the app exits.
  • Model View Design challenge with larger dataset

    Unsolved C++ Gurus
    21
    0 Votes
    21 Posts
    343 Views
    S
    @JonB correct
  • Obtaining MetaData from mp3 files

    Solved General and Desktop
    11
    0 Votes
    11 Posts
    159 Views
    D
    Sooooo, QMediaMetaData tmp = m_mp->metaData(); m_singers = tmp.value(QMediaMetaData::ContributingArtist).toString(); m_title = tmp.value(QMediaMetaData::Title).toString(); m_album = tmp.value(QMediaMetaData::AlbumTitle).toString(); m_duration = tmp.value(QMediaMetaData::Duration).toULongLong(); qDebug() << "Path:" << m_path; qDebug() << "Singers:" << m_singers; qDebug() << "Title:" << m_title; qDebug() << "Album:" << m_album; Works Fine !
  • QtWebengine support on ARM platform

    Unsolved Installation and Deployment
    5
    0 Votes
    5 Posts
    75 Views
    SGaistS
    I would venture that the version of chromium that was provided with 6.2.9 does not support arm builds. You should consider updating Qt to a more recent version. 6.2.9 is very outdated.
  • Setting up Ffmpeg for QT

    Solved General and Desktop
    4
    0 Votes
    4 Posts
    98 Views
    SGaistS
    What was the issue ? It might help other people
  • Using Spotify Web SDK in Qt6

    Solved QtWebEngine
    12
    0 Votes
    12 Posts
    832 Views
    SGaistS
    Please describe the exact setup you are using: Qt version How you got it How you setup your build environment How are trying to build the QtWebengine module
  • Running A Profiled App on X86_64 Android Emulator Qt6.9.1

    Unsolved Mobile and Embedded
    5
    0 Votes
    5 Posts
    72 Views
    SGaistS
    Hi, Are you sure you are closing your application and not just putting it in the background ? Just leaving it to return to the shell (the name is confusing as most people associate shell with a terminal running bash, zsh, etc.) does not equal stopping it. Also return ret; would be the expect way to end your application.
  • Changing the taskbar icon

    Unsolved General and Desktop
    3
    0 Votes
    3 Posts
    97 Views
    T
    You're right it is the icon of my python interpreter. But I still want to change it through code
  • How to disable screensaver on Qt6.9.1 Android App

    Unsolved Mobile and Embedded
    3
    0 Votes
    3 Posts
    39 Views
    SMF-QtS
    @jsulm This compiles and runs: int main(int argc, char *argv[]) { #ifdef ANDROID QJniObject activity = QNativeInterface::QAndroidApplication::context(); if(activity.isValid()) { activity.callMethod<void>("setRequestedOrientation", "(I)V", 0); QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;"); if (window.isValid()) { const int FLAG_KEEP_SCREEN_ON = 128; window.callMethod<void>("addFlags", "(I)V", FLAG_KEEP_SCREEN_ON); } QJniEnvironment env; if (env->ExceptionCheck()) { env->ExceptionClear(); } } ... The call to fix the orientation into landscape works (solution from a previous topic). The call to keep the screen on does not work. The exception check returns false (if that is relevant ???). Am I setting the correct flags ?
  • How move Map

    Solved QML and Qt Quick
    3
    0 Votes
    3 Posts
    90 Views
    Z
    PinchHandler and WheelHandler are for zoom. If you need to move the map you need DragHandler and TapHandler One of them rotates the map, I guess it's not what you want on mobile devices
  • 0 Votes
    7 Posts
    95 Views
    Christian EhrlicherC
    Add the qm files to your resources
  • SkyboxCubeMap rotation?

    Unsolved QML and Qt Quick
    1
    0 Votes
    1 Posts
    36 Views
    No one has replied
  • how to use chatgpt for blogging

    Unsolved Brainstorm
    4
    0 Votes
    4 Posts
    95 Views
    JoeCFDJ
    Have not used chatgpt for a while. I prefer Grok.
  • UB or not

    Unsolved General and Desktop
    9
    0 Votes
    9 Posts
    334 Views
    Christian EhrlicherC
    @DmitryTS said in UB or not: a constant reference extend the life of this temporary object or not? I already answered it...
  • 0 Votes
    4 Posts
    62 Views
    ekkescornerE
    @Pann sorry I forgot these lines in ApplicationWindow: flags: Qt.platform.os === "android"? Qt.Window : Qt.ExpandedClientAreaHint | Qt.NoTitleBarBackgroundHint and Component.onCompleted: if(Qt.platform.os === "android") { window.flags = Qt.ExpandedClientAreaHint | Qt.NoTitleBarBackgroundHint window.visibility = Window.Windowed }
  • Testing Android APK with QtCreator fails with an error.

    Solved Qt Creator and other tools
    35
    0 Votes
    35 Posts
    2k Views
    SMF-QtS
    Build issues solved: [https://forum.qt.io/topic/162537/qt-creator-android-15-adb.exe-pull-system-bin-app_process64-error/]