Change cursor does not work when move mouse from outside of QWidget
-
#include "widget.h" #include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); ui->widget->setCursor(QCursor(Qt::PointingHandCursor)); } Widget::~Widget() { delete ui; } void Widget::resizeEvent(QResizeEvent *event){ ui->widget->setGeometry(0, this->size().height()-50, this->size().width(),50); }
If I move mose from upper part of main widget into the lower part, the cursor changed to a hand
But if I move mouse from outside of main widget into the lwoer part, the cursor won't change to a hand most time
why, and how can I fix this -
#include "widget.h" #include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); ui->widget->setCursor(QCursor(Qt::PointingHandCursor)); } Widget::~Widget() { delete ui; } void Widget::resizeEvent(QResizeEvent *event){ ui->widget->setGeometry(0, this->size().height()-50, this->size().width(),50); }
If I move mose from upper part of main widget into the lower part, the cursor changed to a hand
But if I move mouse from outside of main widget into the lwoer part, the cursor won't change to a hand most time
why, and how can I fix this@pengxu
I would look at reimplementing yourWidget
s hover events, mousemove events, enter/leaveEvents or even event/eventFilter to set your cursor, if you are finding provlems with what you have now. For hover events, at least, you could also implement your desired cursor via stylesheet, which may work better than what you have now in code.