Results 1 to 4 of 4

Thread: Slot doesn't seem to work

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Slot doesn't seem to work

    A pushbutton, pbSave, in the StnInfoDialog form needs to call the slot insertInfo in the stninfodialog.cpp passing the value of the form field 'call'
    Here is the code:

    Qt Code:
    1. #include "stninfodialog.h"
    2. #include "ui_stninfodialog.h"
    3. #include "makestndb.h"
    4. #include "insertstninfo.h"
    5. #include <QDebug>
    6.  
    7. StnInfoDialog::StnInfoDialog(QWidget *parent) :
    8. QDialog(parent),
    9. m_ui(new Ui::StnInfoDialog)
    10. {
    11. m_ui->setupUi(this);
    12.  
    13. connect(m_ui->pbSave, SIGNAL(clicked(bool)),
    14. this, SLOT(insertInfo(m_ui->call->text())));
    15. }
    16. }
    17.  
    18. void StnInfoDialog::insertInfo(QString mycall)
    19. {
    20. InsertStnInfo insert;
    21. insert.insertStnInfo(mycall);
    22. }
    To copy to clipboard, switch view to plain text mode 

    Problem is, the slot never gets called when pbSave is clicked.
    Can someone please show me what I am doing wrong?

  2. #2
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Slot doesn't seem to work

    [QUOTE=waynew;121836]

    Qt Code:
    1. connect(m_ui->pbSave,
    2. SIGNAL(clicked(bool)), this,
    3. SLOT(insertInfo(m_ui->call->text())));
    To copy to clipboard, switch view to plain text mode 

    Try this:

    Qt Code:
    1. connect( m_ui->pbSave,
    2. SIGNAL( clicked() ), this,
    3. SLOT( insertInfo( ) ) );
    To copy to clipboard, switch view to plain text mode 

    You can't submit a parameter with insertInfo(). You could create your own signal, but may be a private variable will do the job.

  3. The following user says thank you to gboelter for this useful post:

    waynew (8th November 2009)

  4. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Slot doesn't seem to work

    Tnx gboelter - got it working ok now by eliminating the parameter and getting the form field value while in insertinfo, then passing it to the insert database method.

  5. The following user says thank you to waynew for this useful post:

    gboelter (10th November 2009)

  6. #4
    Join Date
    Oct 2006
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Slot doesn't seem to work

    From Qt Doc:

    Note that the signal and slots parameters must not contain any variable names, only the type.

    The signature of a signal must match the signature of the receiving slot. (In fact a slot may have a shorter signature than the signal it receives because it can ignore extra arguments.

    So:

    use only type: Qstring, int and not QString dummy or int Bignumber, only QString or int.
    If u can use the same number of parameters too.


    Hope this help

Similar Threads

  1. QIODevice dosn't work inside slot
    By s410i in forum Qt Programming
    Replies: 1
    Last Post: 1st August 2009, 11:10
  2. minimize slot does not work in linux.Is it a Bug in Qt?
    By anupamgee in forum Qt Programming
    Replies: 4
    Last Post: 4th June 2009, 08:18
  3. copy() slot doesn't work
    By Macok in forum Qt Programming
    Replies: 3
    Last Post: 14th February 2009, 10:55
  4. Problem When Creating my own Slot
    By Fatla in forum Qt Programming
    Replies: 12
    Last Post: 6th June 2008, 14:44

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.