简体   繁体   中英

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

This code is for VLC Media Player. If I move the mouse in fullscreen, the message and the x,y coordinates get displayed. I want to display a message when I click (left or right) on fullscreen. How can I do this? I'm using 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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