Hey all,
Complete noob to QT here. I am trying to write a gui for a program that I wrote in traditional c++ (command line application) - I want to populate a label widget with a value when I push a button on the GUI. The label's objectName is "label" - and my code looks something like this:
#include "brachygui.h"
#include "ui_brachygui.h"
#include <QLabel>
BrachyGUI
::BrachyGUI(QWidget *parent
) : ui(new Ui::BrachyGUI)
{
ui->setupUi(this);
}
BrachyGUI::~BrachyGUI()
{
delete ui;
}
void BrachyGUI::on_pushButton_clicked()
{
label->setText("Monday");
}
#include "brachygui.h"
#include "ui_brachygui.h"
#include <QLabel>
BrachyGUI::BrachyGUI(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::BrachyGUI)
{
ui->setupUi(this);
}
BrachyGUI::~BrachyGUI()
{
delete ui;
}
void BrachyGUI::on_pushButton_clicked()
{
label->setText("Monday");
}
To copy to clipboard, switch view to plain text mode
When I build, I get the error "error: 'label' was not declared in this scope". Where do I define the label, or is it already defined somewhere, and I need to access it differently? I've searched the forums and google, but haven't been able to work it out
Thanks in advance.
Bookmarks