#include <QObject>
#include <QMessageBox>
{
Q_OBJECT
public:
{}
public slots:
void test()
{
}
};
#include <QObject>
#include <QMessageBox>
class Receiver : public QObject
{
Q_OBJECT
public:
Receiver() : QObject()
{}
public slots:
void test()
{
QMessageBox::information(0, "This", "Is working");
}
};
To copy to clipboard, switch view to plain text mode
#include <QtGui>
#include "object.h"
int main(int argc, char *argv[])
{
Receiver r;
QObject::connect(&sc,
SIGNAL(selectionChanged
()),
&r,
SLOT(test
()));
v.show();
return app.exec();
}
#include <QtGui>
#include "object.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QGraphicsScene sc(0,0,1055,768);
Receiver r;
QGraphicsView v(&sc);
QObject::connect(&sc, SIGNAL(selectionChanged()), &r, SLOT(test()));
QGraphicsLineItem *li = sc.addLine(10,25,326,230,QPen(Qt::green));
QGraphicsRectItem *ri = sc.addRect(50,23,50,50,QPen(Qt::red));
li->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
ri->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
v.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks