Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. qml qt freeze at the time of cpp funtion call
Forum Updated to NodeBB v4.3 + New Features

qml qt freeze at the time of cpp funtion call

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 754 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anas_Deshmukh
    wrote on last edited by Anas_Deshmukh
    #1

    my test application get freeze when i call cpp function, as function finishes everything work fine,, i need to call same cpp function repeatedly.

    sm20.h

    #ifndef SM20_H
    #define SM20_H

    #include <QObject>
    #include <QDateTime>
    #include <QFile>
    #include <QtGui>
    #include <QtCore>
    #include <QTimer>

    class SM20: public QThread
    {
    Q_OBJECT
    public :
    void set_up();
    public slots :
    void testSm20();
    };
    #endif // SM20_H

    main.cpp

    #include "qtquick1applicationviewer.h"
    #include <QApplication>
    #include "sm20.h"
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QtQuick1ApplicationViewer viewer;
    viewer.addImportPath(QLatin1String("modules"));
    viewer.setOrientation(QtQuick1ApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qrc:/main.qml"));
    viewer.showExpanded();

    SM20 sm20;
    //sm20.testSm20();
    

    QObject *object = viewer.rootObject();
    QObject::connect(object, SIGNAL(mySignal()), &sm20, SLOT(testSm20()));
    return app.exec();
    }

    sm20.cpp

    #include <QApplication>
    #include <QTimer>
    #include "FP.h"
    #include "sm20.h"

    void SM20 :: set_up()
    {
    setUp();
    }

    void SM20 :: testSm20()
    {
    setUp();
    qDebug () << "inside test\n";
    ledOn();
    ledOff();
    ledOn();
    ledOff();
    }

    main.qml

    import QtQuick 1.1

    Rectangle {
    width: 480
    height: 270
    signal mySignal()
    Item {
    Timer {
    interval: 10000; running: true; repeat: true
    onTriggered: mySignal()
    }
    }
    }

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Anas_Deshmukh
      wrote on last edited by
      #2

      my program freeze at the time of testSm20().
      help me to rid of this issue.

      1 Reply Last reply
      0
      • jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        First question: why does SM20 inherit from QThread?
        You don't implement void run() method.
        Are you trying to execute void testSm20() in a separate thread? If so then you're doing it wrong.

        What does setUp() do?
        What is in ledOn()?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved