• 5390阅读
  • 4回复

[提问]如何判断一个点(QPoint)是否在某个指定的qwidget里面 [复制链接]

上一主题 下一主题
离线ningfeng8899
 

只看楼主 倒序阅读 楼主  发表于: 2012-08-23
Background / pre-condtion :
For now, I had implemented a QTabWidget control. meanwhile, I also provide the context operation (mouse right click  menu),and it had run successfully.


I append the action ("Remove") into the prior menu and implement the SLOT function for this action.
Because QTabWidget has a default item is 0, When I trigger the Context event. How does the QTabWidget know that current index.
At here, the only clue is the QPoint pt = QCursor::pos(); If I can verify which widget is I request via pt. The issue should be easy.


Pls help me solve this. I will appreciate you!!


BTW:
  you just implement this method: int IsInWidget(QWidget* pwidget, QPoint pt);
           return value means current index of QTabWidget control,
           pWidget means specified Widget. pt means specified point coordinate.
离线tsinhi

只看该作者 1楼 发表于: 2012-08-26
需要重载 qwidget对鼠标事件的操作成员函数吧
离线benbenmajia

只看该作者 2楼 发表于: 2012-08-27
如果只需要widget内,QRect::contains(QPoint())
冲在mousepress时间
安然.....
离线benbenmajia

只看该作者 3楼 发表于: 2012-08-27
如果是很多地方需要,可以自己做一个基类,在widget范围内捕捉touch事件传回指针
安然.....
离线ningfeng8899

只看该作者 4楼 发表于: 2012-08-31
试过不行,QTbbWidge只对自己激活的Tab page 有效,所以你右键菜单到inactive tab page. 它始终是拿不到accurate value!! 可能一楼说得时正确的。但是也比较麻烦!
快速回复
限100 字节
 
上一个 下一个