Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. issue getting a lineEdit to update
QtWS25 Last Chance

issue getting a lineEdit to update

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++lineeditfunction
18 Posts 3 Posters 1.4k 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.
  • D Dean21

    Hi, so as the title says I am trying to get a lineEdit to update a value when a value is received via MQTT, the problem is I cant get the lineEdit to update and even if I put debug statements in they never show so I feel the code is never run but I cant understand why.
    I have tried having a function that I pass the parameter to, which would then update the lineEdit, I have tried just placing the lineEdit setText within the function where the value is that I want to display and a couple other approaches but cant get it to work. Below is a close to minimum example code.
    There are no errors it just doesnt update the line edit when I expect it to,
    Any help would be great,
    Thanks, Dean

    #include "widget.h"
    #include "./ui_widget.h"
    #include <QPalette>
    #include <QDebug>
    #include <QTimer>
    
    
    #include <string>
    #include <cstring>
    #include <iostream>
    #include <time.h>
    #include </home/dave/mosquitto/include/mosquitto.h> //needed for mosquitto MQTT
    
    //-----for qt qrapper for mosquitto-----
    #include <QCoreApplication>
    #include <QTime>
    #include "QMMqttClient.h"
    //--------------------------------------
    
    
    QString msg_as_qstring;
    
    
    //------------IP Adresses------------
    char RPi_IP[] = "130.246.58.64";
    //-----------------------------------
    
    
    Widget::Widget(QWidget *parent)
        : QWidget(parent)
        , ui(new Ui::Widget)
    
    {
        ui->setupUi(this);
    
    //----------To set background colour----------
        QPalette p(palette());
        p.setColor(QPalette::Window, Qt::darkGray);
        setPalette(p);
    //--------------------------------------------
    
    
    //-------------To set Font and Size-------------
        QFont f( "Ubuntu Regular", 13, QFont::Bold);
        ui->LV_Title->setFont(f);
        ui->HV_Title->setFont(f);
        ui->Currently_set_LV->setFont(f);
        ui->Currently_set_HV->setFont(f);
        ui->Light_Level_Title->setFont(f);
        ui->Number_of_photons_Title->setFont(f);
        ui->Light_Level_before_amp_Title->setFont(f);
    
    
        ui->Currently_set_LV_line->setReadOnly(true);
        ui->Currently_set_HV_line->setReadOnly(true);
        ui->Light_Level_Line_Edit->setReadOnly(true);
        ui->Number_of_Photons_Line_Edit->setReadOnly(true);
    //-----------------------------------------------
    
            QObject::connect(&client, &QMMqttClient::onConnected, this ,[this](){
                qDebug() << " QMMqttClient::onConnected handler, subscribe to topic...";
                client.subscribeTopic("command/stop");
            });
    
            QObject::connect(&client, &QMMqttClient::onMessageReceived, [](const QString &topic, const QByteArray &msg) {
                msg_as_qstring = QString(msg);
                qDebug() << "test value is"<< msg_as_qstring;
            });
    
            qDebug() << "msg_as_qstring"<< msg_as_qstring;
    
            msg_functionality(); // issue here
    
            /* An example of unsecure connection */
            client.initialize("12", RPi_IP, 1883);
    
            client.connect();
    
    
    }
    
    Widget::~Widget()
    {
        delete ui;
    }
    
    
    void Widget::msg_functionality(){
    
        qDebug() << "here";
        ui->Light_Level_Line_Edit->setText(msg_as_qstring);
    }
    

    FYI: Using Ubuntu, and creating widget applications in qt creator 6.4.2

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @Dean21 said in issue getting a lineEdit to update:

    even if I put debug statements in they never show

    Do you mean

    qDebug() << "here";
    

    is never printed?

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

    D 1 Reply Last reply
    0
    • jsulmJ jsulm

      @Dean21 said in issue getting a lineEdit to update:

      even if I put debug statements in they never show

      Do you mean

      qDebug() << "here";
      

      is never printed?

      D Offline
      D Offline
      Dean21
      wrote on last edited by
      #3

      @jsulm yes thats correct I never see it printed

      JonBJ 1 Reply Last reply
      0
      • D Dean21

        @jsulm yes thats correct I never see it printed

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #4

        @Dean21
        Comment out every line in Widget::Widget() till there is only

        msg_functionality(); // issue here
        

        left. Do you now get the qDebug() << "here";? Assuming you do, uncomment other lines till you find the problem. Standard programming techniques.

        D 1 Reply Last reply
        1
        • JonBJ JonB

          @Dean21
          Comment out every line in Widget::Widget() till there is only

          msg_functionality(); // issue here
          

          left. Do you now get the qDebug() << "here";? Assuming you do, uncomment other lines till you find the problem. Standard programming techniques.

          D Offline
          D Offline
          Dean21
          wrote on last edited by Dean21
          #5

          @JonB I did what you said and here does show and for some reason now I have commented it out, ran it and now uncommented everything, I do see "here" each time, but still no update in the line edit. If i try to put the function call inside the on_message function then I get an error saying

          error: ‘this’ was not captured for this lambda function
             98 |             msg_functionality();
                |             ~~~~~~~~~~~~~~~~~^~
          
          
          error: cannot call member function ‘void Widget::msg_functionality()’ without object
          

          I have tried creating an object for the function inside my widget.h file object called

          Widget test;
          

          which gives the error

          error: field ‘test’ has incomplete type ‘Widget’
             20 |     Widget test;
                |            ^~~~
          ../FETS_GUI/widget.h:12:7: note: definition of ‘class Widget’ is not complete until the closing brace
             12 | class Widget : public QWidget
                |       ^~~~~~
          

          and globally defined in the widget.cpp at the top of the file, same object name gives

          QWidget: Must construct a QApplication before a QWidget
          

          Thanks in advance for your help,
          Dean

          jsulmJ 1 Reply Last reply
          0
          • D Dean21

            @JonB I did what you said and here does show and for some reason now I have commented it out, ran it and now uncommented everything, I do see "here" each time, but still no update in the line edit. If i try to put the function call inside the on_message function then I get an error saying

            error: ‘this’ was not captured for this lambda function
               98 |             msg_functionality();
                  |             ~~~~~~~~~~~~~~~~~^~
            
            
            error: cannot call member function ‘void Widget::msg_functionality()’ without object
            

            I have tried creating an object for the function inside my widget.h file object called

            Widget test;
            

            which gives the error

            error: field ‘test’ has incomplete type ‘Widget’
               20 |     Widget test;
                  |            ^~~~
            ../FETS_GUI/widget.h:12:7: note: definition of ‘class Widget’ is not complete until the closing brace
               12 | class Widget : public QWidget
                  |       ^~~~~~
            

            and globally defined in the widget.cpp at the top of the file, same object name gives

            QWidget: Must construct a QApplication before a QWidget
            

            Thanks in advance for your help,
            Dean

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @Dean21 said in issue getting a lineEdit to update:

            but still no update in the line edit

            What is the value you're trying to set? Maybe it is empty string?

            "error: ‘this’ was not captured for this lambda function" - simply capture "this" in your lambda:

            QObject::connect(&client, &QMMqttClient::onMessageReceived, [this](const QString &topic, const QByteArray &msg) {
                        msg_as_qstring = QString(msg);
                        qDebug() << "test value is"<< msg_as_qstring;
                    });
            

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

            D 1 Reply Last reply
            0
            • jsulmJ jsulm

              @Dean21 said in issue getting a lineEdit to update:

              but still no update in the line edit

              What is the value you're trying to set? Maybe it is empty string?

              "error: ‘this’ was not captured for this lambda function" - simply capture "this" in your lambda:

              QObject::connect(&client, &QMMqttClient::onMessageReceived, [this](const QString &topic, const QByteArray &msg) {
                          msg_as_qstring = QString(msg);
                          qDebug() << "test value is"<< msg_as_qstring;
                      });
              
              D Offline
              D Offline
              Dean21
              wrote on last edited by
              #7

              @jsulm I did try adding the [this] but is still the same, I do expect it to be an empty string on the first time the code is ran because I havent sent anything on MQTT. Just to let you know I have a raspberry pi that when I run a cmd line command sends the MQTT data.
              I feel as though I need to be able to have the function call inside of the onMessageRecieved function, as when I receive a message I then want to update the lineEdit

              jsulmJ 1 Reply Last reply
              0
              • D Dean21

                @jsulm I did try adding the [this] but is still the same, I do expect it to be an empty string on the first time the code is ran because I havent sent anything on MQTT. Just to let you know I have a raspberry pi that when I run a cmd line command sends the MQTT data.
                I feel as though I need to be able to have the function call inside of the onMessageRecieved function, as when I receive a message I then want to update the lineEdit

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @Dean21 Please post your current code, capturing "this" should work.
                Checking value of the string you're setting is also easy...

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

                D 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Dean21 Please post your current code, capturing "this" should work.
                  Checking value of the string you're setting is also easy...

                  D Offline
                  D Offline
                  Dean21
                  wrote on last edited by
                  #9

                  @jsulm I can post the code but it uses a library that had to be downloaded and setup inside the .pro, just cause if you try to run it without then it wont work, plus you would need to be able to send MQTT data to it, to check if the line edit updates when it should.

                  jsulmJ 1 Reply Last reply
                  0
                  • D Dean21

                    @jsulm I can post the code but it uses a library that had to be downloaded and setup inside the .pro, just cause if you try to run it without then it wont work, plus you would need to be able to send MQTT data to it, to check if the line edit updates when it should.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @Dean21 I don't ask you to post all your code, just the relevant parts (especially your current connect statement with captured "this").

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

                    D 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @Dean21 I don't ask you to post all your code, just the relevant parts (especially your current connect statement with captured "this").

                      D Offline
                      D Offline
                      Dean21
                      wrote on last edited by
                      #11

                      @jsulm sorry for long reply I have to wait 10 minutes between post as I am new user, for completness the code for the QMMqtClient.h and .cpp files are found here in case you wanted to see that as well https://github.com/KostiantynBushko/QMosqMqttClient

                      #include "widget.h"
                      #include "./ui_widget.h"
                      #include <QPalette>
                      #include <QDebug>
                      #include <QTimer>
                      
                      
                      #include <string>
                      #include <cstring>
                      #include <iostream>
                      #include <time.h>
                      #include </home/dave/mosquitto/include/mosquitto.h> //needed for mosquitto MQTT
                      
                      //-----for qt qrapper for mosquitto-----
                      #include <QCoreApplication>
                      #include <QTime>
                      #include "QMMqttClient.h"
                      //--------------------------------------
                      
                      QString msg_as_qstring;
                      
                      
                      Widget::Widget(QWidget *parent)
                          : QWidget(parent)
                          , ui(new Ui::Widget)
                      
                      {
                          ui->setupUi(this);
                      
                      
                              QObject::connect(&client, &QMMqttClient::onConnected, this ,[this](){
                                  qDebug() << " QMMqttClient::onConnected handler, subscribe to topic...";
                                  client.subscribeTopic("command/stop");
                              });
                      
                              QObject::connect(&client, &QMMqttClient::onMessageReceived, [this](const QString &topic, const QByteArray &msg) {
                                  msg_as_qstring = QString(msg);
                                  qDebug() << "test value is"<< msg_as_qstring;
                                  //msg_functionality();
                              });
                      
                              qDebug() << "msg_as_qstring"<< msg_as_qstring;
                      
                              //msg_functionality(); // issue here
                      
                      //        /* An example of unsecure connection */
                              client.initialize("12", RPi_IP, 1883);
                      
                              client.connect();
                      
                      
                      }
                      
                      Widget::~Widget()
                      {
                          delete ui;
                      }
                      
                      
                      void Widget::msg_functionality(){
                      
                          qDebug() << "here";
                          qDebug() << msg_as_qstring;
                          ui->Light_Level_Line_Edit->setText(msg_as_qstring);
                      }
                      
                      jsulmJ JonBJ 2 Replies Last reply
                      0
                      • D Dean21

                        @jsulm sorry for long reply I have to wait 10 minutes between post as I am new user, for completness the code for the QMMqtClient.h and .cpp files are found here in case you wanted to see that as well https://github.com/KostiantynBushko/QMosqMqttClient

                        #include "widget.h"
                        #include "./ui_widget.h"
                        #include <QPalette>
                        #include <QDebug>
                        #include <QTimer>
                        
                        
                        #include <string>
                        #include <cstring>
                        #include <iostream>
                        #include <time.h>
                        #include </home/dave/mosquitto/include/mosquitto.h> //needed for mosquitto MQTT
                        
                        //-----for qt qrapper for mosquitto-----
                        #include <QCoreApplication>
                        #include <QTime>
                        #include "QMMqttClient.h"
                        //--------------------------------------
                        
                        QString msg_as_qstring;
                        
                        
                        Widget::Widget(QWidget *parent)
                            : QWidget(parent)
                            , ui(new Ui::Widget)
                        
                        {
                            ui->setupUi(this);
                        
                        
                                QObject::connect(&client, &QMMqttClient::onConnected, this ,[this](){
                                    qDebug() << " QMMqttClient::onConnected handler, subscribe to topic...";
                                    client.subscribeTopic("command/stop");
                                });
                        
                                QObject::connect(&client, &QMMqttClient::onMessageReceived, [this](const QString &topic, const QByteArray &msg) {
                                    msg_as_qstring = QString(msg);
                                    qDebug() << "test value is"<< msg_as_qstring;
                                    //msg_functionality();
                                });
                        
                                qDebug() << "msg_as_qstring"<< msg_as_qstring;
                        
                                //msg_functionality(); // issue here
                        
                        //        /* An example of unsecure connection */
                                client.initialize("12", RPi_IP, 1883);
                        
                                client.connect();
                        
                        
                        }
                        
                        Widget::~Widget()
                        {
                            delete ui;
                        }
                        
                        
                        void Widget::msg_functionality(){
                        
                            qDebug() << "here";
                            qDebug() << msg_as_qstring;
                            ui->Light_Level_Line_Edit->setText(msg_as_qstring);
                        }
                        
                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        @Dean21 said in issue getting a lineEdit to update:

                        QObject::connect(&client, &QMMqttClient::onMessageReceived, [this](const QString &topic, const QByteArray &msg) {
                        msg_as_qstring = QString(msg);
                        qDebug() << "test value is"<< msg_as_qstring;
                        //msg_functionality();
                        });

                        What exact error do you get if you uncomment msg_functionality()?

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

                        D 1 Reply Last reply
                        1
                        • D Dean21

                          @jsulm sorry for long reply I have to wait 10 minutes between post as I am new user, for completness the code for the QMMqtClient.h and .cpp files are found here in case you wanted to see that as well https://github.com/KostiantynBushko/QMosqMqttClient

                          #include "widget.h"
                          #include "./ui_widget.h"
                          #include <QPalette>
                          #include <QDebug>
                          #include <QTimer>
                          
                          
                          #include <string>
                          #include <cstring>
                          #include <iostream>
                          #include <time.h>
                          #include </home/dave/mosquitto/include/mosquitto.h> //needed for mosquitto MQTT
                          
                          //-----for qt qrapper for mosquitto-----
                          #include <QCoreApplication>
                          #include <QTime>
                          #include "QMMqttClient.h"
                          //--------------------------------------
                          
                          QString msg_as_qstring;
                          
                          
                          Widget::Widget(QWidget *parent)
                              : QWidget(parent)
                              , ui(new Ui::Widget)
                          
                          {
                              ui->setupUi(this);
                          
                          
                                  QObject::connect(&client, &QMMqttClient::onConnected, this ,[this](){
                                      qDebug() << " QMMqttClient::onConnected handler, subscribe to topic...";
                                      client.subscribeTopic("command/stop");
                                  });
                          
                                  QObject::connect(&client, &QMMqttClient::onMessageReceived, [this](const QString &topic, const QByteArray &msg) {
                                      msg_as_qstring = QString(msg);
                                      qDebug() << "test value is"<< msg_as_qstring;
                                      //msg_functionality();
                                  });
                          
                                  qDebug() << "msg_as_qstring"<< msg_as_qstring;
                          
                                  //msg_functionality(); // issue here
                          
                          //        /* An example of unsecure connection */
                                  client.initialize("12", RPi_IP, 1883);
                          
                                  client.connect();
                          
                          
                          }
                          
                          Widget::~Widget()
                          {
                              delete ui;
                          }
                          
                          
                          void Widget::msg_functionality(){
                          
                              qDebug() << "here";
                              qDebug() << msg_as_qstring;
                              ui->Light_Level_Line_Edit->setText(msg_as_qstring);
                          }
                          
                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #13

                          @Dean21
                          ...And while you are answering @jsulm please show widget.h just in case...

                          1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @Dean21 said in issue getting a lineEdit to update:

                            QObject::connect(&client, &QMMqttClient::onMessageReceived, [this](const QString &topic, const QByteArray &msg) {
                            msg_as_qstring = QString(msg);
                            qDebug() << "test value is"<< msg_as_qstring;
                            //msg_functionality();
                            });

                            What exact error do you get if you uncomment msg_functionality()?

                            D Offline
                            D Offline
                            Dean21
                            wrote on last edited by
                            #14

                            @jsulm that doesnt give any errors but I also dont see the debug "here" and same as before lineEdit doesnt update

                            and here is the widget.h file code

                            #ifndef WIDGET_H
                            #define WIDGET_H
                            
                            #include <QWidget>
                            #include <string>
                            #include "QMMqttClient.h"
                            
                            QT_BEGIN_NAMESPACE
                            namespace Ui { class Widget; }
                            QT_END_NAMESPACE
                            
                            class Widget : public QWidget
                            {
                                Q_OBJECT
                            
                            public:
                                Widget(QWidget *parent = nullptr);
                                ~Widget();
                                QMMqttClient client;
                            
                            
                            
                            private slots:
                                void on_pushButton_clicked();
                                void int_or_string_LV();
                                void int_or_string_HV();
                                void Display_Int_Error(int);
                                void Empty_string_Error(int);
                                void Display_Range_Error(int);
                                void Display_Default(int);
                                void Display_success_msg(int);
                                void Vbias_min_max_check(QString, int);
                                void msg_functionality();
                            
                                void on_lineEdit_returnPressed();
                            
                                void on_HV_pushButton_pressed();
                            
                                void on_HV_lineEdit_returnPressed();
                            
                            
                            private:
                                Ui::Widget *ui;
                            
                            
                            };
                            #endif // WIDGET_H
                            
                            
                            jsulmJ 1 Reply Last reply
                            0
                            • D Dean21

                              @jsulm that doesnt give any errors but I also dont see the debug "here" and same as before lineEdit doesnt update

                              and here is the widget.h file code

                              #ifndef WIDGET_H
                              #define WIDGET_H
                              
                              #include <QWidget>
                              #include <string>
                              #include "QMMqttClient.h"
                              
                              QT_BEGIN_NAMESPACE
                              namespace Ui { class Widget; }
                              QT_END_NAMESPACE
                              
                              class Widget : public QWidget
                              {
                                  Q_OBJECT
                              
                              public:
                                  Widget(QWidget *parent = nullptr);
                                  ~Widget();
                                  QMMqttClient client;
                              
                              
                              
                              private slots:
                                  void on_pushButton_clicked();
                                  void int_or_string_LV();
                                  void int_or_string_HV();
                                  void Display_Int_Error(int);
                                  void Empty_string_Error(int);
                                  void Display_Range_Error(int);
                                  void Display_Default(int);
                                  void Display_success_msg(int);
                                  void Vbias_min_max_check(QString, int);
                                  void msg_functionality();
                              
                                  void on_lineEdit_returnPressed();
                              
                                  void on_HV_pushButton_pressed();
                              
                                  void on_HV_lineEdit_returnPressed();
                              
                              
                              private:
                                  Ui::Widget *ui;
                              
                              
                              };
                              #endif // WIDGET_H
                              
                              
                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              @Dean21 Do you see the debug output from

                              qDebug() << "test value is"<< msg_as_qstring;
                              

                              ?

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

                              D 1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @Dean21 Do you see the debug output from

                                qDebug() << "test value is"<< msg_as_qstring;
                                

                                ?

                                D Offline
                                D Offline
                                Dean21
                                wrote on last edited by Dean21
                                #16

                                @jsulm sorry my bad I had the "here" accidentally commented, when I run the program is my full output, I do see both "here" and test value is

                                msg_as_qstring ""
                                void QMMqttClient::initialize(const QString&, const QString&, int) "12" "130.246.58.64" 1883
                                void QMMqttClient::connect()
                                virtual void QMMqttClient::on_connect(int)  Sucessfully connected to host:  "130.246.58.64"  port:  1883
                                 QMMqttClient::onConnected handler, subscribe to topic...
                                void QMMqttClient::subscribeTopic(const QString&) : topic:  "command/stop"
                                virtual void QMMqttClient::on_subscribe(int, int, const int*)  mid:  1 , QoS:  1
                                

                                And then when I receive an MQTT message this is what is displayed I added to the msg_functionality to add new debug line its shown below

                                void Widget::msg_functionality(){
                                    qDebug() << "here";
                                    qDebug() << "msg as string "<< msg_as_qstring;
                                    ui->Light_Level_Line_Edit->setText(msg_as_qstring);
                                }
                                
                                Topic:  "command/stop" , Msg:  "2\u0000"
                                test value is "2\u0000"
                                here
                                msg as string  "2\u0000"
                                

                                edit: Oh I just seen that it is working now but I feel we didnt change anything

                                jsulmJ 1 Reply Last reply
                                0
                                • D Dean21

                                  @jsulm sorry my bad I had the "here" accidentally commented, when I run the program is my full output, I do see both "here" and test value is

                                  msg_as_qstring ""
                                  void QMMqttClient::initialize(const QString&, const QString&, int) "12" "130.246.58.64" 1883
                                  void QMMqttClient::connect()
                                  virtual void QMMqttClient::on_connect(int)  Sucessfully connected to host:  "130.246.58.64"  port:  1883
                                   QMMqttClient::onConnected handler, subscribe to topic...
                                  void QMMqttClient::subscribeTopic(const QString&) : topic:  "command/stop"
                                  virtual void QMMqttClient::on_subscribe(int, int, const int*)  mid:  1 , QoS:  1
                                  

                                  And then when I receive an MQTT message this is what is displayed I added to the msg_functionality to add new debug line its shown below

                                  void Widget::msg_functionality(){
                                      qDebug() << "here";
                                      qDebug() << "msg as string "<< msg_as_qstring;
                                      ui->Light_Level_Line_Edit->setText(msg_as_qstring);
                                  }
                                  
                                  Topic:  "command/stop" , Msg:  "2\u0000"
                                  test value is "2\u0000"
                                  here
                                  msg as string  "2\u0000"
                                  

                                  edit: Oh I just seen that it is working now but I feel we didnt change anything

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #17

                                  @Dean21 So, works now.
                                  Depending on what data you're receiving this could be wrong:

                                  msg_as_qstring = QString(msg);
                                  

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

                                  D 1 Reply Last reply
                                  0
                                  • jsulmJ jsulm

                                    @Dean21 So, works now.
                                    Depending on what data you're receiving this could be wrong:

                                    msg_as_qstring = QString(msg);
                                    
                                    D Offline
                                    D Offline
                                    Dean21
                                    wrote on last edited by Dean21
                                    #18

                                    @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

                                    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