当我拖放到主窗口外时,是否可以覆盖标准“停止”(交叉圆圈)光标?我有非常简单的代码,这对我来说已经足够了。我将PushButton拖到主窗口之外,然后在释放鼠标按钮上,我获得释放鼠标的窗口。就像一个标准的Windows间谍。那么如何在主窗口外覆盖光标呢?
头
class DDButton : public QPushButton
{
Q_OBJECT
public:
explicit DDButton(QWidget *parent = 0);
signals:
public slots:
private:
void mousePressEvent(QMouseEvent *event);
};
CPP
void DDButton::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
drag->setMimeData(mimeData);
drag->setPixmap(cursor.pixmap());
drag->setHotSpot(QPoint(0,0));
//This block not working
QCursor cursor(Qt::OpenHandCursor);
drag->setDragCursor(cursor.pixmap(), Qt::IgnoreAction);
Qt::DropAction dropAction = drag->exec();
//Do something
qDebug()<<"Press";
}
}