maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   I'm learning with Qt and I have a question (https://talk.maemo.org/showthread.php?t=47962)

tdesws 2010-03-21 19:25

I'm learning with Qt and I have a question
 
Hello, I'm trying to learn to code something with Qt by myself, so now I have a problem:
http://edvinas.edas.lt/images/sth7c8gwsnuvm1s237.png
This is what I've made, when i press next it just cleares that 'TEXT TEXT TEXT', i want to know how to make that change to 'TEXT2 TEXT2 TEXT2' and later change that to 'Whatever other text' and so on to change it to other text.
Sorry my english is very bad.

bousch 2010-03-21 20:32

Re: I'm learning with Qt and I have a question
 
Are you using python or c++? If the control displaying "TEXT TEXT TEXT" in your example is a simple label and you are using c++ you should use the label->setText(const QString &text) method.

Your english is fine by the way...

tdesws 2010-03-21 20:39

Re: I'm learning with Qt and I have a question
 
Well i did everything using that mainwindow.ui not coding :| I've started learning with that Qt only like 5hours ago..
And yea it's a label there

TNiga 2010-03-21 20:49

Re: I'm learning with Qt and I have a question
 
In case you haven't already found out (since you are so new to Qt): Qt has very good documentation with nice examples here http://doc.trolltech.com/4.5/index.html

For example: http://doc.trolltech.com/4.5/qlabel.html

tdesws 2010-03-21 20:55

Re: I'm learning with Qt and I have a question
 
omg, I didn't think that so much of everything is to make text change (I didn't make it to work yet) :O

BTW. Can u gudie me what i have to change (to make text text text to text2 text2 text2 and later to something else and so on...) and why? I would be very grateful, here's my current script:
Code:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

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

void MainWindow::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void MainWindow::buttonClickHandler()
{
}

void MainWindow::on_Button_clicked()
{
}

(yes, I know it's totally empty)

Sasler 2010-03-21 21:59

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by tdesws (Post 576282)
omg, I didn't think that so much of everything is to make text change (I didn't make it to work yet) :O

BTW. Can u gudie me what i have to change (to make text text text to text2 text2 text2 and later to something else and so on...) and why? I would be very grateful, here's my current script:
Code:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

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

void MainWindow::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void MainWindow::buttonClickHandler()
{
}

void MainWindow::on_Button_clicked()
{
}

(yes, I know it's totally empty)

If I understood you correctly, you could try this:

Code:

void MainWindow::on_Button_clicked()
{
      ui->label->setText("text2 text2 text2");
}

Assuming that on_Button_clicked() is called when you click "next" and that the QLabel ID is "label".

Hope this helps :)

tdesws 2010-03-21 22:16

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by Sasler (Post 576359)
If I understood you correctly, you could try this:

Code:

void MainWindow::on_Button_clicked()
{
      ui->label->setText("text2 text2 text2");
}

Assuming that on_Button_clicked() is called when you click "next" and that the QLabel ID is "label".

Hope this helps :)

thanks for helping me out, but how do i change that on third click it would change to text3 text3 text3

krk969 2010-03-21 22:52

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by tdesws (Post 576373)
thanks for helping me out, but how do i change that on third click it would change to text3 text3 text3

using a global/class static variable as a counter is an option.

tdesws 2010-03-22 14:05

Re: I'm learning with Qt and I have a question
 
erm.. how do I do that?

gabby131 2010-03-22 14:10

Re: I'm learning with Qt and I have a question
 
this is telling me that QT is like a Programming language or something to do with code, strings and etc....


All times are GMT. The time now is 13:24.

vBulletin® Version 3.8.8