简体   繁体   English

我想在qt中的小部件上单击(向左或向右)时显示一条消息

[英]i want to display a message when i click(left or right) on widget in qt

This code is for VLC Media Player. 此代码适用于VLC Media Player。 If I move the mouse in fullscreen, the message and the x,y coordinates get displayed. 如果我以全屏方式移动鼠标,则会显示该消息和x,y坐标。 I want to display a message when I click (left or right) on fullscreen. 我想在全屏上单击(向左或向右)时显示一条消息。 How can I do this? 我怎样才能做到这一点? I'm using Qt. 我正在使用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);
    }
}

There is a special event for mouse clicks. 单击鼠标有一个特殊事件。

Did you try implementing those? 您是否尝试实施那些方法? Btw. 顺便说一句。 mouseChanged is vlc-specific. mouseChanged是vlc特定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM