我想在qt中单击(左或右)小部件时显示一条消息
i want to display a message when i click(left or right) on widget in qt
此代码适用于VLC媒体播放器。如果我在全屏中移动鼠标,就会显示消息和x,y坐标。我想在全屏上单击(左或右)时显示一条消息。我该怎么做?我正在使用Qt。
void FullscreenControllerWidget::mouseChanged( vout_thread_t *p_vout, int i_mousex, int i_mousey )
{
bool b_toShow;
/* FIXME - multiple vout (ie multiple mouse position ?) and thread safety if multiple vout ? */
qDebug() << "mouse moved"; //ajay
b_toShow = false;
if ((i_mouse_last_move_x == -1 || i_mouse_last_move_y == -1) ||
(abs( i_mouse_last_move_x - i_mousex ) > 2 ||
abs( i_mouse_last_move_y - i_mousey ) > 2 ))
{
i_mouse_last_move_x = i_mousex;
i_mouse_last_move_y = i_mousey;
qDebug() << "mouse move changed x:" << i_mouse_last_move_x; // ajay
qDebug() << "mouse move changed y:" << i_mouse_last_move_y; // ajay
b_toShow = true;
}
if (b_toShow)
{
/* Show event */
IMEvent *eShow = new IMEvent(FullscreenControlShow_Type, 0);
QApplication::postEvent(this, eShow);
/* Plan hide event */
IMEvent *eHide = new IMEvent(FullscreenControlPlanHide_Type, 0);
QApplication::postEvent(this, eHide);
}
}
鼠标点击有一个特殊事件。
- http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#mousePressEvent
- http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#mouseReleaseEvent
你试过执行这些吗?顺便说一下,mouseChanged是特定于vlc的。
相关文章:
- 比较并显示使用最小值(a,b)和最大值(a、b)升序排列的4个数字
- 由于PC显示设置的更改,Qt小部件被部分剪裁
- Gtkmm 窗口为空白,不显示任何小部件或标题
- 显示文件中具有最小给定元音数的单词
- 在QT C++编辑Qtable模型数据时,我需要得到一个小盒子,我需要显示编辑文本,这怎么可能?
- 如何隐藏最大化和最小化按钮并在qml应用程序窗口中显示关闭按钮?
- 稍后初始化的小部件将不会显示在主窗口中
- 如何显示最小跨度树矩阵
- 一个人如何将QT(C )UI分为多个小部件子类,并使其显示与同一类中的所有窗口
- 在Qt小部件应用程序中显示cmd终端
- 应用程序最小化时单击显示桌面/最小化全部
- 尽可能大地显示所有小部件
- 无法获得固定的设置精度双精度以显示小数位
- 显示六个整数中的最小偶数和奇数,而不使用循环和数组
- 如何在显示时调整 QPlainTextEdit 小部件的大小
- QDial 设置范围从 0.00 到 10.00 到小部件显示
- 为什么在将小部件设置为中央时不显示场景
- C++ 创建小部件数组
- 使小部件显示毫秒时出现问题
- 矢量的最小值显示为 0