qt - in c++,how to change label text when the finger move on touch screen? -


i have label on widget , text of number 1. want change number when user move finger or down (up=number 1 ++ , down=number 1--). code text of label not change in console see value changed!!! , best way that?(get touch event , know user finger on touch screen)

#include "mainwindow.h" #include "ui_mainwindow.h"  mainwindow::mainwindow(qwidget *parent) :     qmainwindow(parent),     ui(new ui::mainwindow) {     ui->setupui(this);     qapp->installeventfilter(this); //    grabgesture(qt::swipegesture);     qgraphicsview graphicsview;         graphicsview.setdragmode(qgraphicsview::scrollhanddrag); }  mainwindow::~mainwindow() {     delete ui; }  bool mainwindow::event(qevent *event){     qdebug()<<"event type"<<event->type();      if(event->type() ==129 /*|| event->type() ==2 || event->type() ==5 */)     {         qmouseevent *ms=static_cast<qmouseevent*>(event);         qpoint p=ms->pos(); //        qdebug()<<"point y"<<p.y()<<" , label . y "<<ui->label->y(); //        qdebug()<<"point x"<<p.x()<<" , label . x "<<ui->label->x();         if(p.y()>ui->label->y())         {              goupperlabel();qdebug()<<"up?";         }         else{              gobuttomlabel();             qdebug()<<"down?";         }     } }      void mainwindow::gobuttomlabel(){     int a=ui->label->text().toint();     qdebug()<<"----down-----"<<a;     a-=1; qdebug()<<"----down-----"<<a;     ui->label->settext(qstring::number(a)); }  void mainwindow::goupperlabel(){      int a=ui->label->text().toint();     qdebug()<<"-------up--------"<<a;     a+=1;qdebug()<<"-------up--------"<<a; //    ui->label->settext(qstring::number(a));       ui->label->settext("qstring::number(a)"); } 

this output print in console:

[root@friendlyarm /fgit]# ./ges1 -qws using multi-touch device: /dev/input/event1 (13) event type 109 event type 68 event type 68 event type 68 event type 68 event type 33 event type 203 event type 75 event type 69 event type 69 event type 69 event type 69 event type 69 event type 70 event type 70 event type 70 event type 70 event type 70 event type 13 event type 14 event type 153 event type 153 event type 153 event type 17 event type 26 event type 67 event type 74 event type 76 event type 77 event type 24 event type 99 event type 8 event type 12 event type 76   ////////// in here touch touch in top of label>>>>>  event type 10 event type 127 event type 129 ----up----- 1 ----up----- 2 up? event type 2 event type 77 event type 3 

what wrong :

 if(event->type() ==129)  

where 129 equivalent qevent::hovermove

should try use

if(event->type() ==qevent::mousemove) 

also should returning in event function.

true event handled false otherwise.

in case return true inside if condition, treating event.

return qmainwindow::event(event); otherwise.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -