PDA

View Full Version : strange error in connect()



quickNitin
20th June 2006, 04:51
bqgis_plugin_tcpcock_la-tcpcock.Tpo -c tcpcock.cpp -fPIC -DPIC -o .libs/libqgis_plugin_tcpcock_la-tcpcock.o
tcpcock.cpp: In member function 'virtual void tcpCock::initGui()':
tcpcock.cpp:105: error: no matching function for call to 'tcpCock::connect(QgsMapCanvas*, const char [28], tcpCock* const, const char [25])'
/usr/local/Trolltech/Qt-4.1.2//include/QtCore/qobject.h:174: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/usr/local/Trolltech/Qt-4.1.2//include/QtCore/qobject.h:274: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
make[5]: *** [libqgis_plugin_tcpcock_la-tcpcock.lo] Error 1
make[5]: Leaving directory `/home1/qgis/src/plugins/tcpCock'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home1/qgis/src/plugins/tcpCock'


code of initGui():


void tcpCock::initGui()
{

// Create the action for tool
mQActionPointer = new QAction(QIcon(":/tcpcock/tcpcock.png"),"track", this);
// Set the what's this text
mQActionPointer->setWhatsThis(tr("Replace this with a short description of the what the plugin does"));
// Connect the action to the run
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
// Add the toolbar
mToolBarPointer = new QToolBar((QMainWindow *) mQGisApp, "tcpCock");
mToolBarPointer->setLabel("track");
// Add the to the toolbar
mQGisIface->addToolBarIcon(mQActionPointer);
mQGisIface->addPluginMenu("&tcpCock", mQActionPointer);
connect(mQGisIface->getMapCanvas(),SIGNAL(renderComplete(QPainter *)),this, SLOT(savePainter(QPainter *)));//line no 105
}


both QgsMapCanvas and tcpCock inherits QObject. * mQGisIface is a private member of tcpCock and

e8johan
20th June 2006, 06:40
When inheriting QObject, you must do so publically and QObject must appear first in the list if you use multiple inheritance, e.g. class Foo : public QObject, ... {};

The error message does indicate that they do not inherit QObject, but it could be a missing "public" too.

quickNitin
20th June 2006, 10:49
ya i have taken care of that and i have inherited QObject publically first than anyother class.
declaration code is:

**************/
#ifndef tcpCock_H
#define tcpCock_H

//QT4 includes
#include <QObject>
#include <QPainter>
#include <QtNetwork>
#include <QtGui>
//QGIS includes
#include <qgisapp.h>
#include "../qgisplugin.h"

//forward declarations
class QToolBar;

/**
* \class Plugin
* \brief [name] plugin for QGIS
* [description]
*/
class tcpCock:public QObject , public QgisPlugin
{
Q_OBJECT;
public:
/**
* Constructor for a plugin. The QgisApp and QgisIface pointers are passed by
* QGIS when it attempts to instantiate the plugin.
* @param Pointer to the QgisApp object
* @param Pointer to the QgisIface object.
*/
tcpCock(QgisApp * theApplication, QgisIface * theInterface);
//! Destructor
virtual ~tcpCock();

public slots:
//! init the gui
virtual void initGui();
//! Show the dialog box
void run();
//! unload the plugin
void unload();
//! show the help document
void help();
//!draw a raster layer in the qui
void drawRasterLayer(QString);
//! Add a vector layer given vectorLayerPath, baseName, providerKey ("ogr" or "postgres");
void drawVectorLayer(QString,QString,QString);

private:
int mPluginType;
//! Pointer to our toolbar
QToolBar *mToolBarPointer;
//! Pionter to QGIS main application object
QgisApp *mQGisApp;
//! Pointer to the QGIS interface object
QgisIface *mQGisIface;
//!pointer to the qaction for this plugin
QAction * mQActionPointer;
int x,y;
QTcpServer *tcpServer;
QTcpSocket *tcpSocket;
QPainter *savedPainter;
public slots:
void savePainter(QPainter *);
void settingServer(bool);
void dataAvailable();
void activatingNewConnection();
void render();
signals:
//void dataFound();
void startRender();
};

#endif //tcpCock_H

quickNitin
21st June 2006, 04:33
Also that has been the case i would have got problem with other connects also.



void tcpCock::run()
{
tcpCockGui *myPluginGui=new tcpCockGui(mQGisApp, QgisGui::ModalDialogFlags);
//listen for when the layer has been made so we can draw it
connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));

connect(myPluginGui,SIGNAL(isCheckBoxClicked(bool) ),this,SLOT(settingServer(bool)));
connect(this,SIGNAL(startRender()),this,SLOT(rende r()));
myPluginGui->show();
}

// Unload the plugin by cleaning up the GUI
void tcpCock::unload()
{
// remove the GUI
mQGisIface->removePluginMenu("&tcpCock",mQActionPointer);
mQGisIface->removeToolBarIcon(mQActionPointer);
delete mQActionPointer;
}

This code is also part of same file, but no problem are reported for connect in this slot.
I have very similar code aprt of same package giving no troubles. I don't know how to move forward in it. Please help

jacek
21st June 2006, 12:56
tcpcock.cpp:105: error: no matching function for call to 'tcpCock::connect(QgsMapCanvas*, const char [28], tcpCock* const, const char [25])'
Make sure you have proper #include directive for QgsMapCanvas in that file.