Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Change cursor does not work when move mouse from outside of QWidget
Forum Updated to NodeBB v4.3 + New Features

Change cursor does not work when move mouse from outside of QWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 430 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pengxu
    wrote on last edited by
    #1
    #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

    JonBJ 1 Reply Last reply
    0
    • P pengxu
      #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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @pengxu
      I would look at reimplementing your Widgets 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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved