Skip to content
  • issue getting a lineEdit to update

    Unsolved General and Desktop c++ lineedit function
    18
    0 Votes
    18 Posts
    1k Views
    D
    @jsulm the data that is sent is in the form of a char array, example, char message[] = "message here"; I use QString because before I was using std::string and I was getting errors when trying to submit that to the line edit, I think conversion type errors, using a QString removed that error and thus I just stuck with it. edit: oh it is working now, I feel like we didnt change anything though and we were just going through debug statements
  • 0 Votes
    24 Posts
    4k Views
    jsulmJ
    @Dean21 Please show your current code if something does not work...
  • 0 Votes
    7 Posts
    848 Views
    JoeCFDJ
    not sure how you handle your mqtt messages in qt code. Qt has a mqtt module and you may take a look at it. I guess you may not need a timer. Instead, you create a signal with info when the message comes and connect that signal with any other qt qwidgets for update. No check is needed as well.
  • 0 Votes
    10 Posts
    1k Views
    M
    @SGaist Ok, thanks!
  • Accessing value of vector only once

    Solved General and Desktop header vector performance function
    3
    0 Votes
    3 Posts
    429 Views
    C
    @MEsc said in Accessing value of vector only once: I have another function MainWindow::on_start_clicked() When this Function get called (here via button), values should load in vec. QVector<QString> vec = loadfrom(); That looks like vec is a variable local to the slot attached to the button. You load it and then it is destroyed when the slot exits. If you want the vec object to have a longer lifetime then you need to arrange that. As @Christian-Ehrlicher says, making vec a private member variable of the MainWindow class is probably the right approach. So, class MainWindow: public QMainWindow { ... private: QVector<QString> m_vec }; void MainWindow::on_start_clicked() { ... m_vec = loadfrom(); ... } void MainWindow::on_answer_returned() { ... // do stuff with m_vec ... } This is basic C++ knowledge and not Qt specific.
  • 0 Votes
    1 Posts
    539 Views
    No one has replied
  • 0 Votes
    3 Posts
    433 Views
    M
    @JonB hello, yes I am an beginner in programming. I have like 2 months experience with it. Would you give me an example for my problem please ?
  • 0 Votes
    2 Posts
    391 Views
    SGaistS
    Hi, That's because these classes are no widgets, there are used to build the UI. In you code snippet, you would use self.nextui.hide() to hide the widget that was created with the help of Registration.Ui_Registration. That is the same for all the widgets you created that way.
  • Pointer to a Q_GADGET

    Solved General and Desktop meta-objects pointer function qobject qgagdet
    3
    0 Votes
    3 Posts
    720 Views
    R
    @VRonin Solved! Thanks for your time!
  • 0 Votes
    3 Posts
    2k Views
    lorn.potterL
    It is possible to call c/c++ functions from javascript as well as call javascript from c/c++. Look at https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html
  • 0 Votes
    5 Posts
    2k Views
    M
    @lorn-potter I figured out how to export custom functions, but there's still a problem with exporting the runtime ones. I am adding the -s EXPORTED_RUNTIME_METHODS=UTF8ToString argument and keep receiving "Uncaught RuntimeError: Aborted('UTF8ToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ))" error.
  • Final task upon program termination

    Solved QML and Qt Quick qt5 qml c++ signal & slot function
    3
    0 Votes
    3 Posts
    564 Views
    T
    @fcarney Sweet! That worked, thanks.
  • QML proper using nested functions

    Unsolved QML and Qt Quick qml function nested style button
    2
    0 Votes
    2 Posts
    676 Views
    rrlopezR
    Hi @Kyeiv, I just did a quick test application and it worked for me: main.qml import QtQuick 2.9 import QtQuick.Window 2.2 import "someJSscriptFile.js" as Jss Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Rectangle { id: rect color: Jss.getCurrentColor() anchors.fill: parent } } someJSScriptFile.js function getCurrentColor() { return __getColor(rect.currentValue) } function __getColor(value) { if (rect.pressed) { return "grey" } if(rect.activated === false) { return "white" } if(value ===0) { return "red"; } return "green"; } Is the variable "control" defined in your QML? Or what are you trying to use it for?
  • GUI Freezes When Loop is Started

    Solved QML and Qt Quick qml qml dynamic loop function thread
    7
    0 Votes
    7 Posts
    2k Views
    C
    @jsulm U are da king! I am dealing with QML for months, and just learning the property variables! That kinda saved my life mate! Thank you very much!
  • 0 Votes
    10 Posts
    8k Views
    C
    @J.Hilk Hey, Thank you for all of your help. Solved the problem thanks to you! If there is anyone facing the same issue, solved like this, Created a source file named "restarter" restarter.h #ifndef RESTARTER_H #define RESTARTER_H #include <QObject> class Restarter : public QObject { Q_OBJECT public: explicit Restarter(QObject *parent = nullptr); Q_INVOKABLE void makeRestart(); signals: public slots: }; #endif // RESTARTER_H restarter.cpp (note: my application works as a service named "myservice" on system, so I can not restart it as restarting a regular application.) #include "restarter.h" #include <QProcess> Restarter::Restarter(QObject *parent) : QObject (parent) { } void Restarter::makeRestart() { QProcess::execute("sudo service myservice restart"); } If your application works NOT AS A SERVICE, BUT AN APPLICATION, restarter.cpp #include "restarter.h" #include <QApplication> #include <QProcess> Restarter::Restarter(QObject *parent) : QObject (parent) { } void Restarter::makeRestart() { qApp->quit(); QProcess::startDetached(qApp->arguments()[0], qApp->arguments()); //application restart } You need to register "restarter.cpp" as a QML registery (I know, stupid sentence) So you need to insert these lines in main.cpp #include "restarter.h" qmlRegisterType<Restarter>("closx.restarter", 1, 0, "Restarter"); and use it on your QML file: import closx.restarter 1.0 Restarter { id:restarter } Rectangle{ id: restartbg width: 120 height: 70 radius: 8 color:"black" anchors.centerIn: parent z:344 Text{ anchors.centerIn: parent text:qsTr("Restart") + mytrans.emptyString font.family:GSystem.myriadproita.name font.pixelSize: 18 color: "white" } MouseArea{ anchors.fill: parent onClicked: { restarter.makeRestart() } onPressed: { restartbg.color = "#1c1c1c" } onReleased: { restartbg.color = "black" } } } Again, thanks to @LeLev and @J-Hilk for everything.
  • Access function/slot loader element in listview

    Solved QML and Qt Quick listview loader function
    4
    0 Votes
    4 Posts
    968 Views
    D
    Indeed it works ! I did 2 mistakes, I forgot ".item" after currentItem and I didn't changed currentIndex when I switch between pages because I use positionViewAtIndex. But positionViewAtIndex don't change currentIndex of the listView. Thanks guys !
  • 0 Votes
    28 Posts
    6k Views
    T
    @Pablo-J.-Rogina Thanks for the time to make example code. It didn't work straight away, this because I use qt4.8 and you the newer one probably. So I changed your code to the older syntax to get it working. I would like to thank you and all others for there help! Again I learned a lot! Thanks for helping!
  • Convert strings in a label to a function

    Solved General and Desktop string function
    16
    0 Votes
    16 Posts
    5k Views
    W
    If you guys are still interested in the topic. See https://github.com/chalkwu/control-system. I think it is a basic DIY solution. Cheers.
  • Function after setupUi()

    Solved General and Desktop setup function show
    31
    0 Votes
    31 Posts
    17k Views
    T
    @kshegunov said in Function after setupUi(): Probably flooding the main thread's event loop. Okey I optimized a code little bit: QtConcurrent::run([=]() { int i; int value; double dResult = 1; for(i = 0;i < 20000000;i++) { dResult = qExp(qCos(qTan(qSin(qPow(qSqrt(((((i * 1337) / 7) * 73) * 1329) % 1937),7) * dResult)) / qAsin(qPow(qSin(dResult * i * qTan(1337 * i)), 29)))); if((i % 200000) == 0) { value = i / 200000; emit showResult(QString::number(dResult)); emit pBarSetValue(value); } } emit showResult(QString::number(dResult)); emit pBarSetValue(100); }); It tooks few seconds for my CPU, but yea UI is responsible and progressbar is changing in realtime Problem was because emit showResult(QString::number(dResult)); emit pBarSetValue(i); runs 5000000 times I don't follow. Add a stop signal where? You run a function imperatively with the proposed QtConcurent::run (as C++ is an imperative language), you can't just break in the middle of it ... I dont know, maybe that Quit Application signal will tell to OS scheduler that scheduler has to kill worker thread So only disadvantage of that method is that I cannot stop worker thread in middle of operation? //EDIT, thanks for help :)
  • How to call an object created in another function.

    Solved General and Desktop c++ function
    17
    0 Votes
    17 Posts
    5k Views
    mrjjM
    @ronyNS said: lbl = new Qlabel(); misspelled ? its QLabel ? lbl = new QLabel(); big L ?