私はQTの新しい人です。今、質問は私を混乱させます。
メインウィンドウで次のようにコーディングします。
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QGraphicsView *view = new QGraphicsView;
QGraphicsScene *scene =new QGraphicsScene;
GraphicsTextItem *item = (GraphicsTextItem*)scene->addText(QString("hello world"));
item->setPos(100,100);
scene->addItem(item);
QGraphicsItem *i = scene->itemAt(120,110);
view->setScene(scene);
view->show();
}
クラスGraphicsTextItemはQGraphicsTextItemを継承し、保護されたメソッドmousePressDownは次のように再実装されます。
void GraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
qDebug()<<"mouseDoubleClickEvent happens";
QGraphicsTextItem::mouseDoubleClickEvent(event);
}
アプリケーションは正常に動作しますが、GraphicsTextItemオブジェクトをダブルクリックすると、GraphicsTextItemクラスのmouseDoubleClickEventには何も起こりません。
あなたの反応を期待してください!