Reply
Thread Tools
Posts: 80 | Thanked: 53 times | Joined on Feb 2010 @ Berlin, Germany
#21
Your curly brackets aren't matching. You can easily see that in the main.cpp where you have two closing ones right after each other.
 

The Following User Says Thank You to nath For This Useful Post:
Posts: 67 | Thanked: 27 times | Joined on Mar 2010 @ Danmark
#22
Originally Posted by krk969 View Post
QT is mainly a graphical toolkit that will allow you to create cross platform code with graphical interfaces, you can use it for backend server coding also, if you like
QT is based on C++, so if you know C++ ( even some basics ), you should feel at home.
Nice, I actually haven't programed in C++ since... ages )) I'm going to give it a try
 
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#23
If I remove one i get theese errors:
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 '}' at end of input

C:/Users/Edvinas/Documents/InteractiveHelloWorld/main.cpp:10: error: expected unqualified-id at end of input
 
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#24
Anyone?
 
Posts: 146 | Thanked: 76 times | Joined on Feb 2010 @ Poland
#25
Originally Posted by tdesws View Post
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
Remove the curlys from: main.cpp
and add them to: mainwindow.h

Like someone said before: Compare and match the curly braces

Code:
private:

    { //REMOVE!!
    Ui::MainWindow *ui;
    // member functions
    void MainWindow::initMyWordList();
    // member variables
    static int _clickCounter;
    QStringList _wordList;
    } //REMOVE!!
Remove the curly's from above
__________________
Remember to click Thanks! if this post is of any help

Last edited by Robb; 2010-04-02 at 10:28.
 
Posts: 198 | Thanked: 76 times | Joined on Mar 2010
#26
Originally Posted by tdesws View Post
mainwindow.h:
Code:
class MainWindow : public QMainWindow {
...
}
#endif // MAINWINDOW_H
you are missing the closing bracket. put one } before #endif

main.cpp:
Code:
#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
...
}
here you got one } to much. remove the last }.

every opening bracket (curly, square, round) has to be closed again.
check your ide's or editor's settings -- almost all should have some kind of visual markers helping you to detect those trivial and easily overlocked syntactical errors.
 
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#27
Ok, now i get only this:

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

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

here's mainwindow.h:

#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

 
krk969's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#28
class MainWindow : public QMainWindow;

remove the semicolon from the end of the line, you put a semicolon only when you finish a definition or statement, here the class definition isnt over.
Put the semi-colon at the end of the mainwindow.h after the last curly brace marking the end of the class definition.
__________________
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.”

Last edited by krk969; 2010-04-05 at 20:24.
 
Posts: 23 | Thanked: 0 times | Joined on Dec 2009
#29
Originally Posted by krk969 View Post
class MainWindow : public QMainWindow;

remove the semicolon from the end of the line, you put a semicolon only when you finish a definition or statement, here the class definition isnt over.
Put the semi-colon at the end of the mainwindow.h after the last curly brace marking the end of the class definition.
Did that, but now I get

C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.h:26: error: extra qualification 'MainWindow::' on member 'initMyWordList'
 
Posts: 198 | Thanked: 76 times | Joined on Mar 2010
#30
do what the error says, remove the "extra qualification 'MainWindow::' " at line 26:

void MainWindow::initMyWordList();

should be

void initMyWordList();

in your header you are declaring the class itself, no need for the namespace here.
 
Reply

Thread Tools

 
Forum Jump


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