Results 1 to 3 of 3

Thread: Run Time error: Object::connect: No such slot dlgTextScroller::pbPreview_clicked(app)

  1. #1
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question Run Time error: Object::connect: No such slot dlgTextScroller::pbPreview_clicked(app)

    Dear ................!

    I have a need of QApplication app(int argc,char **argv) variable (which is declared in main.cpp) in pbPreview_clicked() slot.
    /*In dlgtextscroller.h I have defined the slot as follows*/
    private slots:
    virtual void pbPreview_clicked(QApplication *app);


    /*In dlgTextScroller constructor I connected the pbPreview clicked( ) push button signal to dlgTextscroller pbPreview_clicked(app) as follows*/

    dlgTextScroller::dlgTextScroller( QApplication *app, QWidget* parent)
    : QDialog(parent)
    {
    setupUi(this);
    connect( pbPreview, SIGNAL( clicked() ), this, SLOT( pbPreview_clicked(app) ));
    }

    void dlgTextScroller:bPreview_clicked(QApplication *app)
    {
    ...
    ...
    ...
    }

    It doesn't give any comile time error but when I ran, it gives the following error and show the dialog.........

    Object::connect: No such slot dlgTextScroller:bPreview_clicked(app)
    Object::connect: (sender name: 'pbPreview')
    Object::connect: (receiver name: 'dlgTextScroller')

    Thanks in advance........!
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Run Time error: Object::connect: No such slot dlgTextScroller::pbPreview_clicked(

    The QApplication object is accessible through the QCoreApplication::instance() function which return a pointer equivalent to the global qApp pointer
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Run Time error: Object::connect: No such slot dlgTextScroller::pbPreview_clicked(

    Quote Originally Posted by ashukla View Post
    connect( pbPreview, SIGNAL( clicked() ), this, SLOT( pbPreview_clicked(app) ));
    You can't put values, variables and parameter names inside SLOT and SIGNAL macros.

    You can store that pointer in a member variable -- there's no point in passing it as a parameter to a method of the same class. Another solution is to use QCoreApplication::instance().

Similar Threads

  1. How to declare SLOT as a parameter to member function?
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2018, 00:41
  2. QDateTime GMT add sec. or - sec. from locale time....
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2007, 16:39
  3. Problem with pointers while using localtime() and time()
    By jamadagni in forum General Programming
    Replies: 7
    Last Post: 11th January 2006, 15:48

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.