Have you declare Q_OBJECT in header file ?
Have you declare Q_OBJECT in header file ?
a life without programming is like an empty bottle![]()
yes i had done that, if you want i can put header file code also
In the header file did you put the signals after
signals:
and the slots after
private slots:
or
public slots:
Mithin
www.mithin.in
Here is my header file for Cock class
#ifndef Cock_H
#define Cock_H
//QT4 includes
#include <QObject>
#include<QPainter>
//QGIS includes
#include <qgisapp.h>
#include "../qgisplugin.h"
class QToolBar;
class Cockublic QObject, public QgisPlugin
{
Q_OBJECT
public:
Cock(QgisApp * theApplication, QgisIface * theInterface);
//! Destructor
virtual ~Cock();
public slots:
virtual void initGui();
void run();
void unload();
void help();
void renderCock(QPainter *thePainter);
void setEnabled(bool);
void refreshCanvas();
void projectRead();
void drawRasterLayer(QString);
void drawVectorLayer(QString,QString,QString);
private:
bool mEnable;
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;
};
#endif //Cock_H
Are you sure that you are emitting the signal in the correct manner?
Can we see that part of the code as well?
Mithin
www.mithin.in
also use CODE tags becouse we see only some abracadabra
Last edited by zlatko; 1st June 2006 at 11:24.
a life without programming is like an empty bottle![]()
This is the code where i am generating signals. It is in pbnOk_clicked() slot.
#include "cockgui.h"
//qt includes
//standard includes
CockGui::CockGui() : CockGuiBase()
{
setupUi(this);
}
CockGui::CockGui( QWidget* parent, Qt::WFlags fl )
: QDialog ( parent, fl )
{
setupUi(this);
}
CockGui::~CockGui()
{
}
void CockGui:bnOK_clicked()
{
//
// If you have a produced a raster layer using your plugin, you can ask qgis to
// add it to the view using:
// emit drawRasterLayer(QString("layername"));
// or for a vector layer
// emit drawVectorLayer(QString("pathname"),QString("layer name"),QString("provider name (either ogr or postgres"));
//
//close the dialog
hide();
emit enableCock(cBoxAllow->isChecked());
emit enableCockAgain(cBoxAgain->isChecked());
emit needToRefresh();
done(1);
}
void CockGui:bnCancel_clicked()
{
close(1);
}
void CockGui::setBox(bool theBool)
{
cBoxAllow->setChecked(theBool);
}
i couldn't perceive the meaning of CODE tags. Do you want some explanation about what i am trying to achieve.
What i am trying to do is to design a plugin for QGIS( open source map viewer) aiming to display a cock to show direction of wind. I generated form using designer. After that i added my functionality to it. class CockGui handles interaction of logic to dialog and class Cock implements that logic.
I have similar code working there but i don't know what mistake i make here . Ijust couldn't make it out.
mEnable is a boolean flag which tells plugin to whether to display cock or not. mEnable is set by a slot setBox(bool) (code for it already there). setBox(bool) slot is connected to signal generated in accordance with state of checkboxes.
i think i have tried to explain my motive. Anything more required please instruct me.
Writei couldn't perceive the meaning of CODE tags.
"["CODE"]"
Your code. Use the tags without " "
"["/CODE"]"
is pbnOk_clicked() slot called eveytime the button is clicked ?
Mithin
www.mithin.in
yes. I will recheck it but i am confident about it.
thanks man, i think u r right but i am not still sure. While creating dialog i fromed a connection between a slot accept and OK button. I am trying to rectify it now.
any advices are welcome
Can we see the code where you make the connection ?
Mithin
www.mithin.in
quickNitin (2nd June 2006)
i am putting in constructor of CockGui code
connect(pbnOK,SIGNAL(clicked()),this,SLOT(pbnOK_cl icked()));
Bookmarks