Hey, at first i must apologize for my poor english. I am new in Qt and seek for an solution of the follow issue. First my code:
if((obj == ui->stackedWidget) && (ui->stackedWidget->currentIndex() == 1)){
if(ev
->type
() == QEvent::KeyPress) {
if(key.key() == Qt::Key_Control){
ui->stackedWidget->setCurrentIndex(0);
this-> tcpSocket->closeSocket();
}
}
else{
QPoint position
= this
->mapToGlobal
(this
->pos
());
int x = position.x(); int y=position.y();
this->cursor().setPos((x/2)+175, (y/2)+175);
}
return true;
}
}
bool MainWindow::eventFilter(QObject *obj, QEvent *ev){
if((obj == ui->stackedWidget) && (ui->stackedWidget->currentIndex() == 1)){
if(ev->type() == QEvent::KeyPress)
{
QKeyEvent key = static_cast<QKeyEvent>(ev);
if(key.key() == Qt::Key_Control){
ui->stackedWidget->setCurrentIndex(0);
this-> tcpSocket->closeSocket();
}
}
else{
QPoint position = this->mapToGlobal(this->pos());
int x = position.x(); int y=position.y();
this->cursor().setPos((x/2)+175, (y/2)+175);
}
return true;
}
}
To copy to clipboard, switch view to plain text mode
after my attempt to check wether control key was pressed, about a key event in this function, i received folllow error message:
Error: no matching function for call to 'QKeyEvent::QKeyEvent(QEvent*&)'
QKeyEvent key = static_cast<QKeyEvent>(ev);
somebody has an idea??
Bookmarks