Skip to content
  • 144k Topics
    722k Posts
    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?
  • Jobs, project showcases, announcements - anything that isn't directly development
    4k 23k
    4k Topics
    23k Posts
    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. And, the example above shows a blank screen in VirtualBox , with 3D checkbox checked . It only worked in real machines. It seems that D3D backend is not good in VMs.
  • Everything related to designing and design tools

    127 383
    127 Topics
    383 Posts
    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/
  • Everything related to the QA Tools

    77 213
    77 Topics
    213 Posts
    J
    Hello i am using WinCC OA to develop a qt application. WinCC OA has some custom elements which cannot be detected by squish for example a polygon. Squish is now not able to detect this element with the picker. I know the name of the element but as it is of WinCC OA internal i do not know the type: waitForObject( {"container": "container", "name": "POLYGON1","type": "???","visible": 1} ); How do i get this information? And what to use if unknown? Is there any other way? I mainly just need to click this element. Thanks a lot
  • Everything related to learning Qt.

    380 2k
    380 Topics
    2k Posts
    V
    Re: Introducing the QML for Beginners Learning Path & Challenges! Code [image: 0bdec0b3-391b-4146-9139-915587ee26a1.jpg] [image: 5bc25cde-14cc-49b3-bfea-bef4606e6a33.jpg]
  • 2k Topics
    13k Posts
    S
    @JonB correct
  • 4k Topics
    18k Posts
    SGaistS
    @Christian-Ehrlicher moved !
  • This is where all the posts related to the Qt web services go. Including severe sillyness.
    1k 10k
    1k Topics
    10k Posts
    SGaistS
    @RokeJulianLockhart to the best of my knowledge, no. The first release of Discourse was in 2014 and the forum is several years older than that.