In the attachement small example that shows the problem. By default QGraphicsItem must be movable by mouse but he doesn't...

Hi.

I've implemented QGraphicsItem and want to receive mouseReleaseEvent.

I've reimplemented mouseReleaseEvent virtual method but he doesn't invoked.

Why?

I've checked this method with QGraphicsScene and there he works but not in QGraphicsItem.

Why again?



--
Best Regards,
Igor Mironchik.

#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QMainWindow>


class Item
	:	public QGraphicsItem
{
public:
	QRectF boundingRect() const
	{
		return QRectF( 0, 0, 50, 50 );
	}

	void paint( QPainter * painter, const QStyleOptionGraphicsItem * option,
		QWidget * widget )
	{
		Q_UNUSED( option )
		Q_UNUSED( widget )

		painter->setBrush( Qt::green );

		painter->drawRect( boundingRect() );
	}
};


class Window
	:	public QMainWindow
{
public:
	Window()
	{
		init();
	}

private:
	void init()
	{
		QGraphicsView * view = new QGraphicsView( this );
		QGraphicsScene * scene = new QGraphicsScene( this );

		view->setScene( scene );

		Item * item = new Item;
		item->setPos( 0, 0 );
		scene->addItem( item );

		setCentralWidget( view );
	}
};

int main( int argc, char ** argv )
{
	QApplication app( argc, argv );

	Window w;
	w.show();

	return app.exec();
}
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to