Reply
Thread Tools
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#1
Hello, I'm trying to learn to code something with Qt by myself, so now I have a problem:

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.
 
Posts: 117 | Thanked: 60 times | Joined on Nov 2007 @ Amsterdam, NL
#2
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...
 

The Following User Says Thank You to bousch For This Useful Post:
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#3
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
 
Posts: 353 | Thanked: 262 times | Joined on Dec 2009 @ Finland
#4
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
__________________
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client
 

The Following 2 Users Say Thank You to TNiga For This Useful Post:
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#5
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)

Last edited by tdesws; 2010-03-21 at 21:05.
 
Posts: 434 | Thanked: 325 times | Joined on Sep 2009
#6
Originally Posted by tdesws View Post
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
 

The Following User Says Thank You to Sasler For This Useful Post:
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#7
Originally Posted by Sasler View Post
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's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#8
Originally Posted by tdesws View Post
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.
__________________
Developer of :
Buddy - budget/expense manager ( website )
Showtime - a telly channel listing viewer/reminder ( website )
Travelapp - london underground status/planner ( website )
Batlevel - desktop widget for battery level ( website )

I hear and I forget. I see and I remember. I do and I understand.
 
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#9
erm.. how do I do that?
 
Posts: 1,729 | Thanked: 388 times | Joined on Jan 2010 @ Canada
#10
this is telling me that QT is like a Programming language or something to do with code, strings and etc....
 
Reply

Thread Tools

 
Forum Jump


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