PDA

View Full Version : custom signals vs newbie



Raccoon29
21st April 2008, 15:35
A question that shall be answered in two past half seconds:
compiler complains that "variable or field 'result' declared void"
and the code to which refers is this:


class frmmanager: public QWidget
{
[...]
signals:
void result(EViewport win, int id); //<--this line
};

here must be a noobie mistake...
a tiny peluche bear to the first who answers :)

wysota
21st April 2008, 15:43
Check that all the brackets and braces are closed properly. Could we see the part you have cut out?

Raccoon29
21st April 2008, 15:51
To avoid any misunderstanding, here is the entire .h:


#ifndef MANAGER_H
#define MANAGER_H

#include <QtGui>
#include <QString>
#include "ui_manager.h"
#include "CTableWidgetItem.h"
#include "viewports.h"

class frmmanager:public QWidget
{
Q_OBJECT

private:
CViewports *viewport;
QString vTable;
int vWindow;
bool vName;

private slots:
void updateTable();
void close();
void takeId(int row,int col);
void curTakeId();
void parseChecks();
void addentry();
void lightReturn();

void pick();
void pick1();
void pick2();
void pick3();
void pick4();
void pick5();
void pick6();
void pick7();
void pick8();
void pick9();
void pick10();

protected:
void initWidgetGeometry();
void closeEvent(QCloseEvent *event);
void setupTable();
void connectActions();
void populateTable(QSqlQuery *query,int n);
void darkReturn();
QString sanitize(QString str);

public:
frmmanager();
~frmmanager();
void setViewport(CViewports *view);
Ui::frmmanager ui;

void load(QString name, int win, bool name=false);

signals:
void result(EViewport win,int id); // the line is this
};

#endif // MANAGER_H

wysota
21st April 2008, 16:00
What is the last line of viewports.h?

Raccoon29
21st April 2008, 16:09
What is the last line of viewports.h?
Uhm... sorry I miss your goal, what do you mean?
Trying to guess, I post the last lines of viewports.h


class CViewports: public QObject
{
[...]
public:
[...]
frmarticle* Article();
frmviewarticles* ViewArticles();
frmmanager* Manager();
frmcontacts* Contacts();
frmcontact* Contact();
frmsizes* Sizes();
frmsize* Size();
frmtrends* Trends();
frmtrend* Trend();
frmums* Ums();
frmum* Um();
frmgms* Gms();
frmgm* Gm();
};

#endif // VIEWPORTS_H_INCLUDED


If you can be more precise, I'll show all you need.

wysota
21st April 2008, 16:13
I'll try to explain what the problem is and maybe you'll find a solution yourself without showing us all the code :)

The compiler thinks void result(...) is a declaration of a variable and not a function. It might be because there is something wrong with "EViewport" or because the compiler is confused by some earlier error (that's why I asked about viewports.h). You can try removing the signals: keyword and check if the problem persists.

Raccoon29
21st April 2008, 16:29
Ok, fixed, just for change you were right again :D

No, signals: cut out made no difference.
The problem was that in viewports.h I included manager.h (the error file), but the definition of EViewport came after the manager inclusion, so:


// viewports.h
#include "manager.h" // manager.h still doesn't know EViewport, so raises error
enum EViewport{
[...]
}


PS: the tiny peluche bear will be delivered at your home, just leave your address to the operator :p
Thanks again.