PDA

View Full Version : Connecting slots/signals in subclassed form



qball2k5
7th March 2006, 16:51
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



#ifndef DECKSIMULATOR_H
#define DECKSIMULATOR_H

#include <QtGui/QMainWindow>

#include "ui_simulator.h"

class DeckSimulator : public QMainWindow
{
Q_OBJECT

public:
DeckSimulator(QMainWindow *parent = 0);
~DeckSimulator();


private:
Ui::MainWindow ui;

private slots:
void startpump_TP();
void stoppump_TP();
void startpump_DP();
void stoppump_DP();
void startpump_ACP();
void stoppump_ACP();
void startpump_RP();
void stoppump_RP();
};

#endif


here's the cpp



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <QtGui>
#include <QtDebug>
#include "simulator.h"

DeckSimulator::DeckSimulator(QMainWindow *parent)
: QMainWindow(parent)

{
// Setup the GUI
ui.setupUi(this);

// Connect to GUI signals
connect(ui.btnStart_TP, SIGNAL(clicked()), this, SLOT(startpump_TP()));
connect(ui.btnStop_TP, SIGNAL(clicked()), this, SLOT(stoppump_TP()));

}

// Destructor
DeckSimulator::~DeckSimulator()
{

}

void DeckSimulator::startpump_TP()
{
ui.pixTransferPump->setText("Hello");
QPixmap pixmap(QString::fromUtf8("pump_start_image_100.png"));
ui.pixTransferPump->setPixmap(pixmap);
}

void DeckSimulator::stoppump_TP()
{
ui.pixTransferPump->setText("Goodbye");
QPixmap pixmap(QString::fromUtf8("pump_stop_image_100.png"));
ui.pixTransferPump->setPixmap(pixmap);
}

void DeckSimulator::startpump_DP()
{

}

void DeckSimulator::stoppump_DP()
{

}

void DeckSimulator::startpump_ACP()
{

}

void DeckSimulator::stoppump_ACP()
{

}

void DeckSimulator::startpump_RP()
{

}

void DeckSimulator::stoppump_RP()
{

}


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

I'm out of ideas!

zlatko
7th March 2006, 16:56
Is connection available? Can you see some debug message in console?
Try use breakpoint and checkout it

qball2k5
7th March 2006, 17:01
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!