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-04-06 12:46

Re: I'm learning with Qt and I have a question
 
:S now i get those:

C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:33: error: expected initializer before 'void'

C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:41: error: declaration of 'void MainWindow::initMyWordList()' outside of class is not definition

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

mainwindow.cpp:
Quote:

#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())
{ //maybe
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
} //maybe
}

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("test.txt");
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++]) );
}

gunni 2010-04-06 13:14

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

void MainWindow::buttonClickHandler()
should be
Code:

void MainWindow::buttonClickHandler()
{
}

and
Code:

do whatever you feel like
should be
Code:

// do whatever you feel like

tdesws 2010-04-06 13:22

Re: I'm learning with Qt and I have a question
 
C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:35: error: no 'void MainWindow::on_Button_clicked()' member function declared in class 'MainWindow'

C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:43: error: declaration of 'void MainWindow::initMyWordList()' outside of class is not definition

Then i get that :( omg so much errors

Robb 2010-04-06 13:29

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

Originally Posted by tdesws (Post 597661)
C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:35: error: no 'void MainWindow::on_Button_clicked()' member function declared in class 'MainWindow'

C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:43: error: declaration of 'void MainWindow::initMyWordList()' outside of class is not definition

Then i get that :( omg so much errors

Change:
Code:

// do whatever you feel like
into:
Code:

{ } // do nothing
or
Code:

; // do nothing

gunni 2010-04-06 13:32

Re: I'm learning with Qt and I have a question
 
When you once saw most of the errors next time you may correct them yourself. But you should learn a bit more basics of c++ so you would understand the errors.

Quote:

C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:35: error: no 'void MainWindow:n_Button_clicked()' member function declared in class 'MainWindow'C:/Users/Edvinas/Documents/InteractiveHelloWorld/mainwindow.cpp:35: error: no 'void MainWindow:n_Button_clicked()' member function declared in class 'MainWindow'
Means you need to declacre the function first in the header file (add it like the initMyWordList to the .h file)
Code:

void On_Button_clicked();

gunni 2010-04-06 13:55

Re: I'm learning with Qt and I have a question
 
Oh, and
Code:

error = initMyWordList();
wont work, as you declared the function as "void" so it cant return a value.

Venemo 2010-04-19 20:37

Re: I'm learning with Qt and I have a question
 
I'm also new to Qt.

I have a simple question: How do I make a dialog window uncloseable? I mean, how to create a QDialog (or a QMessageBox) which can't be closed by the user, but only the application itself?

krk969 2010-04-20 07:36

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

Originally Posted by Venemo (Post 618351)
... how to create a QDialog (or a QMessageBox) which can't be closed by the user, but only the application itself?

see if this works for you

mikhas 2010-04-20 07:57

Re: I'm learning with Qt and I have a question
 
http://doc.trolltech.com/4.6/qwidget.html#closeEvent

Reimplement this event handler to ignore the close event on a certain condition. Also see the example which explains why this can be useful.

Venemo 2010-04-20 10:35

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

Originally Posted by krk969 (Post 618904)
see if this works for you

I already tried modality, but there seems to be no value to set it to for the desired effect.


All times are GMT. The time now is 18:17.

vBulletin® Version 3.8.8