Results 1 to 14 of 14

Thread: How to pass a string to a function on a connect signal

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to pass a string to a function on a connect signal

    maybe you forgot the Q_OBJECT macro? is searchfunc" defined as a slot?

  2. #2
    Join Date
    Nov 2010
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to pass a string to a function on a connect signal

    Quote Originally Posted by FelixB View Post
    maybe you forgot the Q_OBJECT macro? is searchfunc" defined as a slot?
    Hi FelixB

    This is what i have in the mainwindow.h file

    Qt Code:
    1. private slots:
    2. void searchfunc(QString searchtext);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to pass a string to a function on a connect signal

    hi @jins ,

    as FelixB said, did u forget the Q_OBJECT macro.

    Qt Code:
    1. class myclass : public QWidget
    2. {
    3. Q_OBJECT
    4. private slots:
    5. void searchfunc(QString searchtext);
    6. }
    To copy to clipboard, switch view to plain text mode 

    did u include #include <QtGui>

    pls check

    pls post the class part
    Bala
    Last edited by BalaQT; 30th November 2010 at 12:17.

  4. #4
    Join Date
    Nov 2010
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to pass a string to a function on a connect signal

    Quote Originally Posted by BalaQT View Post
    hi @jins ,

    as FelixB said, did u forget the Q_OBJECT macro.

    Qt Code:
    1. class myclass : public QWidget
    2. {
    3. Q_OBJECT
    4. private slots:
    5. void searchfunc(QString searchtext);
    6. }
    To copy to clipboard, switch view to plain text mode 

    PLS CHECK

    Bala
    I have the QObject specified already, I am sorry i didnt paste the entire code before here it is:


    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. explicit MainWindow(QWidget *parent = 0);
    7. ~MainWindow();
    8.  
    9. private:
    10. Ui::MainWindow *ui;
    11.  
    12. DB* dbManager;
    13. bool opendb;
    14. QList<PersonData*> persondata;
    15.  
    16. private slots:
    17. void searchfunc(QString searchtext);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to pass a string to a function on a connect signal

    did u include #include <QtGui>

    Bala

  6. #6
    Join Date
    Nov 2010
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to pass a string to a function on a connect signal

    Hi Bala

    I have #include <QtGui/QApplication > in main.cpp but just in case i have also added #include <QtGui> and i am still getting the error message.

  7. #7
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to pass a string to a function on a connect signal

    hi,
    how u r compiling?
    try qmake-qt4

    clean all the files, delete all the obj files and then try qmake-qt4


    shall i know where u r using connect?
    pls post the connect block

    Bala

  8. #8
    Join Date
    Nov 2010
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: How to pass a string to a function on a connect signal

    Ok i will like to publically apoligise for my stupidity, i had cut and pasted the connect line outside MainWindow::MainWindow setup and didnt realise. I am so sorry for wasting your time but also very greatful for all your help and advice (BalaQT the third argument you advised worked a dream)

  9. #9
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Thumbs up Re: How to pass a string to a function on a connect signal

    Quote Originally Posted by jins View Post
    Ok i will like to publically apoligise for my stupidity, i had cut and pasted the connect line outside MainWindow::MainWindow setup and didnt realise. I am so sorry for wasting your time but also very greatful for all your help and advice (BalaQT the third argument you advised worked a dream)
    hi jins,
    its nice the problem is solved
    all the best for ur work.
    Bala

Similar Threads

  1. Replies: 2
    Last Post: 12th June 2010, 02:21
  2. Replies: 14
    Last Post: 1st December 2009, 20:45
  3. Connect button and pass QListView current index
    By been_1990 in forum Qt Programming
    Replies: 3
    Last Post: 30th November 2009, 16:20
  4. Replies: 4
    Last Post: 21st June 2009, 18:06
  5. How to pass a QComboBox to a function?
    By Ricardo_arg in forum General Programming
    Replies: 4
    Last Post: 9th March 2008, 22:16

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.