View Single Post
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#20
now it looks like that:

mainwindow.h:
Code:
#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
main.cpp:
Code:
#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}
}
mainwindows.cpp:
Code:
#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++]) );
}
And i get:

C:/Users/Edvinas/Documents/InteractiveHelloWorld/main.cpp:2: In file included from main.cpp:2:

C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.h:24: error: expected unqualified-id before '{' token

C:/Users/Edvinas/Documents/InteractiveHelloWorld/main.cpp:10: error: expected unqualified-id at end of input