Hi all,
maybe someone can help me with this.
I have a project with 1 mainWindow and 1 modal dialog.
What I am trying to do is to pass to the client a variable from the main Window. The code looks like this:
1. Parent:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include <qfiledialog.h>
#include <qmessagebox.h>
#include <qsqldatabase.h>
#include "dlgdbconnection.h"
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void mainReport::fileNew()
{
frmMain->setPaletteBackgroundColor(QColor(255,255,255));
}
void mainReport::fileSave()
{
QString fName=QFileDialog::getSaveFileName("/home/oduma","XML Files(*.xml)",this,"save file dialog","Save");
if(fName.find(".xml",0,FALSE)==-1)
fName +=".xml";
QMessageBox::information(this,"Reports","File to be saved: "+fName);
}
void mainReport::fileSaveAs()
{
QString fName=QFileDialog::getSaveFileName("/home/oduma","XML Files(*.xml)",this,"save file dialog","Save");
if(fName.find(".xml",0,FALSE)==-1)
fName +=".xml";
QMessageBox::information(this,"Reports","File to be saved: "+fName);
}
void mainReport::toolBarConnect()
{
QSqlDatabase *curdbConnection;
dlgDBConnection repDBC;
repDBC.communicate(curdbConnection);
repDBC.exec();
}
|
2. child:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <qmessagebox.h>
#include <qsqldatabase.h>
#define DB_DRIVER "QMYSQL3"
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void dlgDBConnection::dbConnect()
{
QSqlDatabase *curDB=QSqlDatabase::addDatabase(DB_DRIVER);
if(!curDB)
{
txtConnectionStatus->setPaletteForegroundColor(QColor(255,0,0));
txtConnectionStatus->setText("Failed to connect!");
this->_isConnected=-1;
}
else
{
curDB->setDatabaseName(edtDatabase->text());
curDB->setUserName(edtUser->text());
curDB->setPassword(edtPassword->text());
curDB->setHostName(edtServer->text());
if(curDB->open())
{
txtConnectionStatus->setPaletteForegroundColor(QColor(0,0,255));
txtConnectionStatus->setText("Connected");
this->_isConnected=1;
}
else
{
txtConnectionStatus->setPaletteForegroundColor(QColor(255,0,0));
txtConnectionStatus->setText("Failed to connect!");
this->_isConnected=-1;
}
}
}
void dlgDBConnection::communicate( QSqlDatabase *par1)
{
}
|
When I am compiling the project (make) I am getting this error:
In file included from .ui/dlgdbconnection.cpp:10:
.ui/dlgdbconnection.h:45: error: `QSqlDatabase' was not declared in this scope
.ui/dlgdbconnection.h:45: error: `par1' was not declared in this scope
.ui/dlgdbconnection.h:45: error: invalid data member initialization
.ui/dlgdbconnection.h:45: error: (use `=' to initialize static data members)
.ui/dlgdbconnection.h:45: error: variable or field `communicate' declared void
.ui/dlgdbconnection.h:45: error: `communicate' declared as a `virtual' field
line 45 is the line:
void dlgDBConnection::communicate( QSqlDatabase *par1)
If I am replacing the QSqlDatabase pointer with a pointer to an int it works OK.
Can anyone help me with this?
Thanks alot,
tDuma
admin edit:
please use the code tags. tuxipuxi