PDA

View Full Version : Callback in QT



gajendersingh
7th August 2007, 10:04
i have got a widget and a child of the same widget. if i drag and drop some image on child i want parent parent to be notified about the same. i want a callback function to be there in parent, which will be notified about droped contents in child widget.

and i want QDragObject and drop coordinate information to be sent to that call back function in parent widget.


class lab: public QLabel // this is child control
{
public:
lab(QWidget *parent);

protected:
void dragEnterEvent(QDragEnterEvent *event);
void dragLeaveEvent(QDragLeaveEvent *event);
void dropEvent(QDropEvent *event);
};

class Thumbnail : public QWidget // this is parent in which child is created
{
Q_OBJECT
public:
Thumbnail(QWidget *parent = 0)
{
t = new lab(this);
}
~Thumbnail();
private:
lab *t;

}

can you plz tell me how to write above said callback function.

jpn
7th August 2007, 11:52
Qt has signals and slots (http://doc.trolltech.com/4.3/signalsandslots.html) which are way more convenient to use than writing a callback mechanisms by hand.