前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Qt浅谈之九:Qt鼠标

Qt浅谈之九:Qt鼠标

作者头像
bear_fish
发布2018-09-20 14:37:43
2K0
发布2018-09-20 14:37:43
举报

http://blog.csdn.net/taiyang1987912/article/details/35281407

一、简介

       Qt一共有19种鼠标形状,外加自定义的形状。可以查看Qt帮助文档enum Qt::CursorShape,本文主要集中总结,通过图像准确了解。

二、运行图

程序运行,显示如下图1所示。

三、代码

       Qt::BlankCursor隐藏鼠标形状,自定义鼠标只需要添加QCursor *myCursor= new QCursor(QPixmap(":/images/cursor-self.png"),-1,-1);。

[cpp] view plaincopy

  1. void Cursor::slotArrow()  
  2. {  
  3.     setCursor(Qt::ArrowCursor);  
  4. }  
  5. void Cursor::slotBusy()  
  6. {  
  7.     setCursor(Qt::BusyCursor);  
  8. }  
  9. void Cursor::slotCloseHand()  
  10. {  
  11.     setCursor(Qt::ClosedHandCursor);  
  12. }  
  13. void Cursor::slotCross()  
  14. {  
  15.     setCursor(Qt::CrossCursor);  
  16. }  
  17. void Cursor::slotForbidden()  
  18. {  
  19.     setCursor(Qt::ForbiddenCursor);  
  20. }  
  21. void Cursor::slotHand()  
  22. {  
  23.     setCursor(Qt::PointingHandCursor);  
  24. }  
  25. void Cursor::slotHSplit()  
  26. {  
  27.     setCursor(Qt::SplitHCursor);  
  28. }  
  29. void Cursor::slotIbeam()  
  30. {  
  31.     setCursor(Qt::IBeamCursor);  
  32. }  
  33. void Cursor::slotOpenHand()  
  34. {  
  35.     setCursor(Qt::OpenHandCursor);  
  36. }  
  37. void Cursor::slotSizeAll()  
  38. {  
  39.     setCursor(Qt::SizeAllCursor);  
  40. }  
  41. void Cursor::slotSizeB()  
  42. {  
  43.     setCursor(Qt::SizeBDiagCursor);  
  44. }  
  45. void Cursor::slotSizeF()  
  46. {  
  47.     setCursor(Qt::SizeFDiagCursor);  
  48. }  
  49. void Cursor::slotSizeH()  
  50. {  
  51.     setCursor(Qt::SizeHorCursor);  
  52. }  
  53. void Cursor::slotSizeV()  
  54. {  
  55.     setCursor(Qt::SizeVerCursor);  
  56. }  
  57. void Cursor::slotUpArrow()  
  58. {  
  59.     setCursor(Qt::UpArrowCursor);  
  60. }  
  61. void Cursor::slotVSplit()  
  62. {  
  63.     setCursor(Qt::SplitVCursor);  
  64. }  
  65. void Cursor::slotWait()  
  66. {  
  67.     setCursor(Qt::WaitCursor);  
  68. }  
  69. void Cursor::slotWhatsThis()  
  70. {  
  71.     setCursor(Qt::WhatsThisCursor);  
  72. }  
  73. void Cursor::slotBlank()  
  74. {  
  75.     setCursor(Qt::BlankCursor);  
  76. }  
  77. void Cursor::slotCustom()  
  78. {  
  79.     QCursor *myCursor= new QCursor(QPixmap(":/images/cursor-self.png"),-1,-1);  
  80.     setCursor(*myCursor);  
  81. }  

四、总结

(1)该源码比较简单,只需要对Qt的鼠标形状有了解即可。

(2)源码已经打包上传到csdn上可登录下载(http://download.csdn.net/detail/taiyang1987912/7561583)。 

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015年05月04日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • http://blog.csdn.net/taiyang1987912/article/details/35281407
  • 一、简介
  • 二、运行图
  • 三、代码
  • 四、总结
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档