首页| 论坛| 消息
主题:Qt编写输入法V2019终极版
liudianwu发表于 2019-08-15 15:51
pdate();
return true;
}
}
} else if (watched == ui->labMore) {
if (event->type() == QEvent::MouseButtonPress) {
if (inputType == "chinese" && !upper && labCn.first()->isEnabled()) {
if (!ui->widgetChinese->isVisible()) {
ui->widgetLetter->setVisible(false);
ui->widgetNumber->setVisible(false);
ui->widgetChinese->setVisible(true);
} else {
ui->widgetLetter->setVisible(true);
ui->widgetNumber->setVisible(false);
ui->widgetChinese->setVisible(false);
}
//重新设置图标
QString strMore = ui->widgetMore->isVisible() ? "up" : "down";
ui->labMore->setPixmap(QString(":/image/btn_%1_%2.png").arg(strMore).arg(iconType));
return true;
}
}
} else if (watched == ui->labType) {
if (event->type() == QEvent::MouseButtonPress) {
if (inputType == "english") {
setInputType("chinese");
} else if (inputType == "chinese") {
setInputType("english");
}
}
} else if (watched == ui->labType2) {
if (event->type() == QEvent::MouseButtonPress) {
setInputType("english");
}
} else if (watched == ui->widgetCn) {
//没有汉字或者按下的地方没有汉字或者当前汉字标签个数过少都不用继续
if (!labCn.first()->isEnabled() || lastText.isEmpty()) {
return false;
}
//记住最后按下拖动的时间,过短则认为是滑动,启动滑动动画
static bool pressed = false;
static QPoint lastPos = QPoint();
static QDateTime lastTime = QDateTime::currentDateTime();
QMouseEvent *mouseEvent = static_cast(event);
if (event->type() == QEvent::MouseButtonPress) {
pressed = true;
lastPos = mouseEvent->pos();
animationCn->stop();
lastTime = QDateTime::currentDateTime();
} else if (event->type() == QEvent::MouseButtonRelease) {
pressed = false;
if (lastPos != mouseEvent->pos()) {
//判断当前时间和鼠标按下事件比较,时间短则说明是滑动
QDateTime now = QDateTime::currentDateTime();
if (lastTime.msecsTo(now) < 600) {
//可以改变下面的值来调整幅度
bool moveleft = (mouseEvent->pos().x() - lastPos.x()) < 0;
int offset = moveleft ? 350 : -350;
int value = ui->scrollAreaCn->horizontalScrollBar()->value();
animationCn->setStartValue(value);
animationCn->setEndValue(value + offset);
animationCn->start();
}
}
} else if (event->type() == QEvent::MouseMove) {
if (pressed && labCn.first()->isEnabled()) {
//计算滑过的距离
bool moveleft = (mouseEvent->pos().x() - lastPos.x()) < 0;
int offset = moveleft ? 5 : -5;
int value = ui->scrollAreaCn->horizontalScrollBar()->value();
ui->scrollAreaCn->horizontalScrollBar()->setValue(value + offset);
return true;
}
}
} else if (watched == ui->widgetMore) {
//没有汉字或者按下的地方没有汉字或者当前汉字标签个数过少都不用继续
if (!labMore.first()->isEnabled() || lastText.isEmpty()) {
return false;
}
//记住最后按下拖动的时间,过短则认为是滑动,启动滑动动画
static bool pressed = false;
static QPoint lastPos = QPoint();
static QDateTime lastTime = QDateTime::currentDateTime();
QMouseEvent *mouseEvent = static_cast(event);
if (event->type() == QEvent::MouseButtonPress) {
pressed = true;
lastPos = mouseEvent->pos();
animationMore->stop();
lastTime = QDateTime::currentDateTime();
} else if (event->type() == QEvent::MouseButtonRelease) {
pressed = false;
if (lastPos != mouseEvent->pos()) {
//判断当前时间和鼠标按下事件比较,时间短则说明是滑动
QDateTime now = QDateTime::currentDateTime();
if (lastTime.msecsTo(now) < 600) {
//可以改变下面的值来调整幅度
bool movebottom = (mouseEvent->pos().y() - lastPos.y()) < 0;
int offset = movebottom ? 150 : -150;
int value = ui->scrollAreaMore->verticalScrollBar()->value();
animationMore->setStartValue(value);
animationMore->setEndValue(value + offset);
animationMore
下一页上一页  (2/7)
回帖(12):
12楼:请问该输入法能像搜狗输入法一样,适用于各种情况下的输入吗?能不能将该输入法设置为电脑默认输 ..
11楼:fengwujiutan:大侠,请教一下,我下载了一个别人写的输入法,安装电脑上后不能使用,请问是什么 ..
10楼:大侠,请教一下,我下载了一个别人写的输入法,安装电脑上后不能使用,请问是什么原因?需要注册 ..

全部回帖(12)»
最新回帖
收藏本帖
发新帖