Results 1 to 3 of 3

Thread: Connecting slots/signals in subclassed form

  1. #1
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Connecting slots/signals in subclassed form

    Hey!

    I'm trying to connect the buttons on my form to the some slots that I have created in my subclassed form. Basically I'm not sure that the connection is happening to make the actions I need to happen...happen.

    Right now it just changes a pixmap from one image to another. Both images are present...but nothing appears to happen here's my code.

    Here's the class containing the UI form

    Qt Code:
    1. #ifndef DECKSIMULATOR_H
    2. #define DECKSIMULATOR_H
    3.  
    4. #include <QtGui/QMainWindow>
    5.  
    6. #include "ui_simulator.h"
    7.  
    8. class DeckSimulator : public QMainWindow
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. DeckSimulator(QMainWindow *parent = 0);
    14. ~DeckSimulator();
    15.  
    16.  
    17. private:
    18. Ui::MainWindow ui;
    19.  
    20. private slots:
    21. void startpump_TP();
    22. void stoppump_TP();
    23. void startpump_DP();
    24. void stoppump_DP();
    25. void startpump_ACP();
    26. void stoppump_ACP();
    27. void startpump_RP();
    28. void stoppump_RP();
    29. };
    30.  
    31. #endif
    To copy to clipboard, switch view to plain text mode 

    here's the cpp

    Qt Code:
    1. #include <stdio.h>
    2. #include <stdlib.h>
    3. #include <string.h>
    4. #include <time.h>
    5. #include <QtGui>
    6. #include <QtDebug>
    7. #include "simulator.h"
    8.  
    9. DeckSimulator::DeckSimulator(QMainWindow *parent)
    10. : QMainWindow(parent)
    11.  
    12. {
    13. // Setup the GUI
    14. ui.setupUi(this);
    15.  
    16. // Connect to GUI signals
    17. connect(ui.btnStart_TP, SIGNAL(clicked()), this, SLOT(startpump_TP()));
    18. connect(ui.btnStop_TP, SIGNAL(clicked()), this, SLOT(stoppump_TP()));
    19.  
    20. }
    21.  
    22. // Destructor
    23. DeckSimulator::~DeckSimulator()
    24. {
    25.  
    26. }
    27.  
    28. void DeckSimulator::startpump_TP()
    29. {
    30. ui.pixTransferPump->setText("Hello");
    31. QPixmap pixmap(QString::fromUtf8("pump_start_image_100.png"));
    32. ui.pixTransferPump->setPixmap(pixmap);
    33. }
    34.  
    35. void DeckSimulator::stoppump_TP()
    36. {
    37. ui.pixTransferPump->setText("Goodbye");
    38. QPixmap pixmap(QString::fromUtf8("pump_stop_image_100.png"));
    39. ui.pixTransferPump->setPixmap(pixmap);
    40. }
    41.  
    42. void DeckSimulator::startpump_DP()
    43. {
    44.  
    45. }
    46.  
    47. void DeckSimulator::stoppump_DP()
    48. {
    49.  
    50. }
    51.  
    52. void DeckSimulator::startpump_ACP()
    53. {
    54.  
    55. }
    56.  
    57. void DeckSimulator::stoppump_ACP()
    58. {
    59.  
    60. }
    61.  
    62. void DeckSimulator::startpump_RP()
    63. {
    64.  
    65. }
    66.  
    67. void DeckSimulator::stoppump_RP()
    68. {
    69.  
    70. }
    To copy to clipboard, switch view to plain text mode 

    I've tried setting the text to change...but nothing happens...I've tried the images...nothing happens.

    I'm out of ideas!

  2. #2
    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: Connecting slots/signals in subclassed form

    Is connection available? Can you see some debug message in console?
    Try use breakpoint and checkout it
    a life without programming is like an empty bottle

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

    qball2k5 (7th March 2006)

  4. #3
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Connecting slots/signals in subclassed form

    I'm not to bright!

    I have had some things defined incorrectly. I had the main calling a ui file directly instead of going through the sub class. I was just moving to fast....no everything works no problem.

    Thanks for the quick response...i just needed a tac hammer to the melon!

Similar Threads

  1. Replies: 1
    Last Post: 7th August 2007, 09:27
  2. Connecting signal to form that is closing
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 18th May 2007, 08:54

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.