PDA

View Full Version : A signal/slot connect isn't working.



Daimonie
15th February 2009, 23:10
Hey,
for a little project of mine, i've build a little dialog.

Now, when the dialog finishes, the dialog's buttonBox should send out the accept () signal.



bool acceptedConnection = connect (
this->dialog, SIGNAL (accepted ()),
this, SLOT (dataFilledIn())
);

qDebug ( acceptedConnection?
"acceptedConnection made":
"acceptedConnection FAILED"
);
//connecting rejectedConnection
bool rejectedConnection = connect (
this->dialog->buttonBox, SIGNAL (rejected ()),
qApp, SLOT (closeAllWindows())
);

qDebug ( rejectedConnection?
"rejectedConnection made":
"rejectedConnection FAILED"
);
As you can see, i'm connecting everything in exacly the same way. But for some reason,
dataFilledIn () never gets called. The debugger tells me nothing about this; connect returns true.

The following is the header file. I hope you can find something that i've missed.

thanks in advance!:)

#ifndef DATADOWNLOADER_H
#define DATADOWNLOADER_H
#include <QWidget>
class HTTPObject;
class TorpiaAnalyserSettings;
class mainwindow;

class DataDownloader : public QWidget {
Q_OBJECT
public:
DataDownloader (QWidget *);
public slots:
void dataFilledIn ();

void usernameUpdated (QString );
void passwordUpdated (QString );
void intervalUpdated (int);
void maxRequestUpdated (int);
void rankStartUpdated (int);
void rankEndUpdated (int);

void useDownload (int);

private:
HTTPObject * downloader;
TorpiaAnalyserSettings * dialog;
mainwindow * window;

void connectSignals (int);
public: /*properties*/
QString username;
QString password;
int interval;
int maxRequest;
int rankStart;
int rankEnd;

};

#endif

talk2amulya
15th February 2009, 23:24
accepted () is emitted only when u click OK button on the dialog.. r u clickin the OK button only? also, note that the signal wont be emitted when the dialog is hidden or its not visible..make sure all criterias of the signal being emitted are met..otherwise, there is no reason why the slot wont be called

Daimonie
15th February 2009, 23:27
accepted () is emitted only when u click OK button on the dialog.. r u clickin the OK button only? also, note that the signal wont be emitted when the dialog is hidden or its not visible..make sure all criterias of the signal being emitted are met..otherwise, there is no reason why the slot wont be called

I am indeed clicking the ok button. As you can see, the program exits when i click the other one.

Now, i just noticed i didn't gave all information.



DataDownloader::DataDownloader (QWidget * parent = 0)
:QWidget (parent)
{
.......

this->dialog->show ();


this->connectSignals (1);
}




void DataDownloader::dataFilledIn ()
{
qDebug ( "Requesting downloads, showing mainwindow and ignoring the dialog");
this->connectSignals (2);
this->window->show ();
this->dialog->done (1);
..............
}

talk2amulya
15th February 2009, 23:37
is this a customized dialog u r using? i ask it cuz of this


this->dialog->buttonBox

normally there is no buttonBox in the QDialog as far as i know

Daimonie
15th February 2009, 23:42
Oh, sorry.
The dialog is created through a QT Designer interface, a ui file. Sorry that i didn't mention that :P

hm. In the designer, i've removed the default signal/slot.

I think i know the problem, brb , testing it.

Oke, it was my own fault.

By removing those connections, i've removed the signal that was sent out.

fixed! thanks :)

talk2amulya
15th February 2009, 23:46
i think in one of the connect statements, u have used

this->dialog

and other u have used

this->dialog->buttonBox

there must be ur issue..signal isnt properly connected..

Daimonie
15th February 2009, 23:55
i think in one of the connect statements, u have used

this->dialog

and other u have used

this->dialog->buttonBox

there must be ur issue..signal isnt properly connected..

and that too, is true :)

It would seem that i'm a bit too easy with things. need to pay more attention :)