Hi,
Yes I am fine with C++, but I am new to Qt. I have already tried what you suggest. I am dragging from a QListWidget derived class to a QGraphicsView derived class. In my code I have the following: -
{
protected:
void startDrag(Qt::DropActions /*supportedActions*/)
{
ba = item->text().toLatin1().data();
mimeData->setData("application/x-my-custom-item", ba);
drag->setMimeData(mimeData);
drag->exec(Qt::MoveAction);
}
{
qDebug("EdaSymbolListWidget Key Event: %x", key->key());
}
};
class EdaSymbolListWidget : public QListWidget
{
protected:
void startDrag(Qt::DropActions /*supportedActions*/)
{
QListWidgetItem *item = currentItem();
QMimeData *mimeData = new QMimeData;
QByteArray ba;
ba = item->text().toLatin1().data();
mimeData->setData("application/x-my-custom-item", ba);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->exec(Qt::MoveAction);
}
void keyPressEvent(QKeyEvent *key)
{
qDebug("EdaSymbolListWidget Key Event: %x", key->key());
QListWidget::keyPressEvent(key);
}
};
To copy to clipboard, switch view to plain text mode
I also have the following override in my QGraphicsView derived class
void MyGraphicsView
::keyPressEvent(QKeyEvent *key
) {
qDebug("View Key Event: %x", key->key());
}
void MyGraphicsView::keyPressEvent(QKeyEvent *key)
{
qDebug("View Key Event: %x", key->key());
QGraphicsView::keyPressEvent(key);
}
To copy to clipboard, switch view to plain text mode
When I focus the list or view I get the key presses in the debug window as I would expect. However, once a start a drag operation from the QListWidget pressing keys no longer calls the keyPressEvent in either view, and thats where I am stuck
Gerry
Bookmarks