Results 1 to 18 of 18

Thread: signal not getting communicated to slot

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: signal not getting communicated to slot

    Have you declare Q_OBJECT in header file ?
    a life without programming is like an empty bottle

  2. #2
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signal not getting communicated to slot

    yes i had done that, if you want i can put header file code also

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signal not getting communicated to slot

    In the header file did you put the signals after

    signals:

    and the slots after

    private slots:

    or

    public slots:

  4. #4
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signal not getting communicated to slot

    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

  5. #5
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signal not getting communicated to slot

    Are you sure that you are emitting the signal in the correct manner?

    Can we see that part of the code as well?

  6. #6
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: signal not getting communicated to slot

    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

  7. #7
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signal not getting communicated to slot

    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.

  8. #8
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signal not getting communicated to slot

    i couldn't perceive the meaning of CODE tags.
    Write

    "["CODE"]"

    Your code. Use the tags without " "

    "["/CODE"]"

    is pbnOk_clicked() slot called eveytime the button is clicked ?

  9. #9
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signal not getting communicated to slot

    yes. I will recheck it but i am confident about it.

  10. #10
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signal not getting communicated to slot

    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

  11. #11
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signal not getting communicated to slot

    Can we see the code where you make the connection ?

  12. The following user says thank you to munna for this useful post:

    quickNitin (2nd June 2006)

  13. #12
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signal not getting communicated to slot

    i am putting in constructor of CockGui code

    connect(pbnOK,SIGNAL(clicked()),this,SLOT(pbnOK_cl icked()));

Similar Threads

  1. Manually send signal to slot
    By donmorr in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2006, 15:03
  2. Replies: 2
    Last Post: 17th May 2006, 21:01
  3. no such signal QListBox::currentChanged()
    By jopie bakker in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 15:17
  4. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52
  5. No such signal...
    By chaimar in forum Qt Programming
    Replies: 12
    Last Post: 24th January 2006, 22:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.