SchindlerShadow
November 27th, 2010, 06:42 PM
ok i got a really stupid question.
i just finished learning c++, and just started Qt, its a bit over whelming. no real straight forward book.
ok so i got a label and a line edit in mainwindow.
i want to assign whatever is in the line edit to x
and assign label = to x
label is called label
line edit is lineEdit
i try this:
in MainWindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <string>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
string x; //normal string dosent work for some reason even with <string>
x = "Hello World";
x = ui->lineEdit->textChanged();
ui->label->text() = x;
}
MainWindow::~MainWindow()
{
delete ui;
}
and i get some crazy errors like
'string' was not declared in this scope line 10 //wtf?
expected ';' before 'x' line 10 //i did that, dident i?
invalid use of member (did you forget the '&' ?) line 11 // why do i need &?
no matching function for call to 'QlineEdit::textChanged()' line 12
no match for 'operator=' in 'QLabel::text() const() = ((MainWindow*)this)->QWidget::x' line 13 //wtf?
maybe im not putting it in the right place? thanks for any help!
i just finished learning c++, and just started Qt, its a bit over whelming. no real straight forward book.
ok so i got a label and a line edit in mainwindow.
i want to assign whatever is in the line edit to x
and assign label = to x
label is called label
line edit is lineEdit
i try this:
in MainWindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <string>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
string x; //normal string dosent work for some reason even with <string>
x = "Hello World";
x = ui->lineEdit->textChanged();
ui->label->text() = x;
}
MainWindow::~MainWindow()
{
delete ui;
}
and i get some crazy errors like
'string' was not declared in this scope line 10 //wtf?
expected ';' before 'x' line 10 //i did that, dident i?
invalid use of member (did you forget the '&' ?) line 11 // why do i need &?
no matching function for call to 'QlineEdit::textChanged()' line 12
no match for 'operator=' in 'QLabel::text() const() = ((MainWindow*)this)->QWidget::x' line 13 //wtf?
maybe im not putting it in the right place? thanks for any help!