Skip to content
  • 144k Topics
    722k Posts
    SMF-QtS
    Yes I was using "return ret;" How would you suggest I close my App? Thanks
  • 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.
  • Everything related to designing and design tools

    127 383
    127 Topics
    383 Posts
    R
    I see this is an old thread and I see several unresolved threads on this topic. I'm leaving this incase it helps someone else who ends up here. The solution was twofold for me. Go to File > Export Project and select Enable Python Generator. This will create a main.py. Make sure you pip install PySide6-DS Hope this helps someone.
  • 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.