wrong connected line with multi-touch in iOS using my code



  • I deploy my code on android.
    Then, it will draw separable line by each finger.
    Question 1:
    But when I deploy my code on iOS(iPad),
    it will connect the line between the different finger. ,That is not what I want.
    Why ? And how to correct it?

    Question 2:
    I put a pushbutton on my code.
    The below text is my current code.
    But I can't click the button on my android and iOS.
    Should I change some thing in my code?

    Question 3:
    In fact, I just want to ZoomIn or ZoomOut my graph by finger.
    I watch some video in Qt studio. But I don't find any example....

    TouchTest::TouchTest(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::TouchTest)
    {
        ui->setupUi(this);
        this->setAttribute(Qt::WA_AcceptTouchEvents, true);
        connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(onClear_clicked()));
    }
    
    bool TouchTest::event(QEvent *e){
        switch (e->type()) {
        case QEvent::TouchBegin: {
            return true;
        }
        case QEvent::TouchUpdate:{
        }
        case QEvent::TouchEnd:
        {
            QTouchEvent *te = static_cast<QTouchEvent *>(e);
            this->addLine(te);
            return true;
        }
        case QEvent::Paint:
        {
            paintEvent((QPaintEvent *)e);
        }
        default:;
        }
        return QWidget::event(e);
    }
    
    void TouchTest::addLine(QTouchEvent *e)
    {
        QLineF line;
        QList<QTouchEvent::TouchPoint> touchPoints = e->touchPoints();
        foreach (QTouchEvent::TouchPoint i , touchPoints){
            qDebug()<<"i.pos()"<<i.pos()<<"i.lastPos()"<<i.lastPos();
            line.setP1(i.lastPos());
            line.setP2(i.pos());
            this->lines.push_back(line);
        }
        this->update();
    }
    
    void TouchTest::paintEvent(QPaintEvent *event){
        QPainter painter(this);
        painter.drawLines(this->lines);
        painter.end();
    }
    
    void TouchTest::onClear_clicked()
    {
        this->lines.clear();
        this->update();
    }
    
    TouchTest::~TouchTest()
    {
        delete ui;
    }
    

    PS:
    QVector<QLineF> lines;


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.