Accessing the value from line edit..
-
Hey folks..I am a beginner and trying out my first QT program. I am having problem accessing value from line edit. First I created a design using QT windows.ui and then wanted to access value from 3 different line edits in the design and perform calculation. but I really dont have any idea how to . I looked up in the API and everywhere... I know it should be something really easy but I cant figure it out...With the following code I have an error stating "class Qlabel has no member named value". I would appreciate bunch if anyone could explain me the solution. Thanks in advance !
@
#include<QtGui>
#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->Search,SIGNAL(clicked()),this,SLOT(on_Search_clicked()));
connect(ui->Submit,SIGNAL(clicked()),this,SLOT(on_Submit_clicked()));
connect(ui->Clear,SIGNAL(clicked()),this,SLOT(on_Clear_clicked()));
connect(ui->Add,SIGNAL(clicked()),this,SLOT(on_Add_clicked()));}
MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::on_Search_clicked()
{}
void MainWindow::on_Submit_clicked()
{
int value1;
int value2;value1= ui->saleprice->value(); value2=ui->original->value();
}
void MainWindow::on_Clear_clicked()
{}
void MainWindow::on_Add_clicked()
{}
@[EDIT: code formatting, please wrap in @-tags, Volker]
-
You posted code, but not UI definition, so I can only guess that saleprice is QLabel.
Indeed, class Qlabel has no member named value, but text (if that is what you are looking for).
From doc: "text : QString - This property holds the label's text."
Same applies for QLineEdit, no member named value, but text (QString).Go to "qt doc":http://doc.qt.nokia.com/4.7/index.html then in search index edit box write word "value" and hit enter, there you can find all Qt classes which have value as property or method (not much of them), and draw a conclusion - Qt have a bit different naming conventions compared to Java, but you will get it if you browse doc or use code completion in Qt Creator.
-
stemd thanks for the information. I will for sure check qt doc and try to figure out. I will post again if I run into problem.