| The Following User Says Thank You to krk969 For This Useful Post: | ||
|
|
2010-03-22
, 15:05
|
|
|
Posts: 754 |
Thanked: 630 times |
Joined on Sep 2009
@ London
|
#12
|
this is telling me that QT is like a Programming language or something to do with code, strings and etc....

|
|
2010-03-22
, 17:57
|
|
Posts: 23 |
Thanked: 0 times |
Joined on Dec 2009
|
#13
|
mainwindow.h
mainwindow.cppCode:class MainWindow { ........ private: static int _clickCounter; };
in the first line of the file just after all the #includes define this variable,
and modfiy your slot with something like thisCode:int MainWindow::_clickCounter = 0;
Code:void MainWindow::on_Button_clicked() { ui->label->setText(QString("this is text %1").arg(QString::number(++_clickCounter) ); }
|
|
2010-03-22
, 17:58
|
|
|
Posts: 754 |
Thanked: 630 times |
Joined on Sep 2009
@ London
|
#14
|
| The Following User Says Thank You to krk969 For This Useful Post: | ||
|
|
2010-03-22
, 18:08
|
|
Posts: 23 |
Thanked: 0 times |
Joined on Dec 2009
|
#15
|
so you want to print a random text from a list every time you click ?
whats the requirement ?
|
|
2010-03-22
, 18:21
|
|
|
Posts: 754 |
Thanked: 630 times |
Joined on Sep 2009
@ London
|
#16
|
Well I have like 500 lines of text
and i want it to show next line everytime i press next
class MainWindow
{
...
private: // member functions
void MainWindow::initMyWordList();
private: // member variables
static int _clickCounter;
QStringList _wordList;
};
in the first line of the file just after all the #includes define this variable,
int MainWindow::_clickCounter = 0;
and in
MainWindow()
{
....
error = initMyWordList();
if ( error )
do whatever you feel like
....
}
//init my word file
void MainWindow::initMyWordList()
{
QFile * wordFile = new QFile("/home/user/wordlist");
wordFile->open(QIODevice::ReadOnly);
QTextStream stream(wordFile);
// create the map of channel and date until which data is available
while ( !stream.atEnd() )
{
QString word = stream.readLine();
_wordList << word;
}
wordFile->close();
}
void MainWindow::on_Button_clicked()
{
ui->label->setText(QString("the word of the day is %1").arg(_wordList[_clickCounter++]) );
}
|
|
2010-03-24
, 13:44
|
|
Posts: 23 |
Thanked: 0 times |
Joined on Dec 2009
|
#17
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
void buttonClickHandler();
protected:
void changeEvent(QEvent *e);
private:
Ui::MainWindow *ui;
{
private: // member functions
void MainWindow::initMyWordList()
private: // member variables
static int _clickCounter;
QStringList _wordList;
};
private slots:
private slots:
void on_Button_clicked();
};
#endif // MAINWINDOW_H
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>
int MainWindow::_clickCounter = 0;
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()
{
....
error = initMyWordList();
if ( error )
do whatever you feel like
....
}
//init my word file
void MainWindow::initMyWordList()
{
QFile * wordFile = new QFile("/home/user/wordlist");
wordFile->open(QIODevice::ReadOnly);
QTextStream stream(wordFile);
// create the map of channel and date until which data is available
while ( !stream.atEnd() )
{
QString word = stream.readLine();
_wordList << word;
}
wordFile->close();
}
void MainWindow::on_Button_clicked()
{
ui->label->setText(QString("the word of the day is %1").arg(_wordList[_clickCounter++]) );
}
|
|
2010-03-24
, 14:13
|
|
|
Posts: 1,070 |
Thanked: 1,604 times |
Joined on Sep 2008
@ Helsinki
|
#18
|
| The Following User Says Thank You to VDVsx For This Useful Post: | ||
|
|
2010-03-24
, 14:14
|
|
|
Posts: 754 |
Thanked: 630 times |
Joined on Sep 2009
@ London
|
#19
|
Here's my window.h
but when i try to build i get: C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.h:24: error: expected unqualified-id before '{' tokenCode:.... private: Ui::MainWindow *ui; { private: // member functions void MainWindow::initMyWordList() private: // member variables static int _clickCounter; QStringList _wordList; };
| The Following User Says Thank You to krk969 For This Useful Post: | ||
|
|
2010-03-24
, 14:52
|
|
Posts: 23 |
Thanked: 0 times |
Joined on Dec 2009
|
#20
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
void buttonClickHandler();
protected:
void changeEvent(QEvent *e);
private:
{
Ui::MainWindow *ui;
// member functions
void MainWindow::initMyWordList();
// member variables
static int _clickCounter;
QStringList _wordList;
}
//private slots:
//void on_Button_clicked();
#endif // MAINWINDOW_H
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>
int MainWindow::_clickCounter = 0;
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()
{
error = initMyWordList();
if ( error )
do whatever you feel like
}
//init my word file
void MainWindow::initMyWordList()
{
QFile * wordFile = new QFile("C:\Users\Edvinas\Desktop\MAEMO\N900\Development\test");
wordFile->open(QIODevice::ReadOnly);
QTextStream stream(wordFile);
// create the map of channel and date until which data is available
while ( !stream.atEnd() )
{
QString word = stream.readLine();
_wordList << word;
}
wordFile->close();
}
void MainWindow::on_Button_clicked()
{
ui->label->setText(QString("the word of the day is %1").arg(_wordList[_clickCounter++]) );
}
class MainWindow { ........ private: static int _clickCounter; };in the first line of the file just after all the #includes define this variable,
void MainWindow::on_Button_clicked() { ui->label->setText(QString("this is text %1").arg(QString::number(++_clickCounter) ); }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.”