Temp data to lcd widget



  • I am new to GUI development and don't have much experience in C++ either. I am trying to print my temperature data to the lcd widget when pressed pushbutton. Temperature data is coming from bluetooth server and stored in a struct.

    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    extern "C"{
    #include "defines.h"
    }

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_Temp_Button_clicked()
    {
    struct Measurement_Data *m_Data;

    m_Data = L2CAP_server();
    

    }

    void MainWindow::on_Humi_Button_clicked()
    {

    }

    void MainWindow::on_lcdNumber_overflow()
    {

    }@

    If you could show me how I can get the temp data printet to lcd widget when pressed that pushbutton named Temp_Button.



  • Hi,
    Just to make life easy, why not use a QLineEdit as a readonly object to first store your value in. Then when that all works, check out how to show the data in the LCDWidget.
    The QLineEdit has a setText function. Convert the m_Data value (a member of that struct) to a QString and set the text.
    When we do not have the m_Data struct definition there is no way we are able to show any code.



  • Oh sorry forgot that struct definition.

    @struct Measurement_Data {

    float temp;
    float humi;
    };@



  • Ah, that is a bit more easy to understand then ;-)
    Isn't it just:
    @
    ui->yourLcdWidget.display(m_Data.temp);
    @



  • error: '((MainWindow*)this)->MainWindow:ui->Ui:MainWindow:<anonymous>.Ui_MainWindow:lcdNumber' cannot be used as a function


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.