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. Accessing the value from line edit..

Accessing the value from line edit..

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.5k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    Ajon2733
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stemd
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Ajon2733
        wrote on last edited by
        #3

        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.

        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