hlp:640x480-小屏vx4齿轮泵代码提交

This commit is contained in:
kite_lucs
2026-09-10 15:19:23 +08:00
commit b1ff3223e9
1534 changed files with 237996 additions and 0 deletions
+143
View File
@@ -0,0 +1,143 @@
/*
* MyTextEdit.cpp
*
* Created on: Aug 7, 2013
* Author: yiyu
* QQ:1036184468
* Descriptoin:
*/
#include <MyTextEdit.h>
#include "SysPara.h"
#include <QTextDocument>
#include <QTextCursor>
#include <QTextBlockFormat>
#include <QTextBlock>
#include <QDebug>
#include <QKeyEvent>
#include <QWSServer>
MyTextEdit::MyTextEdit(QWidget *parent):QTextEdit(parent){
this->document()->setDocumentMargin(0);
// QTextDocument *doc = this->document(); //获取文档对象
// QTextFrame *rootFrame = doc->rootFrame(); //获取根框架
// QTextFrameFormat frameFormat; //创建框架格式
// frameFormat.setBorderBrush(Qt::red); //设置边界颜色
// frameFormat.setBorder(0); //设置边界宽度
// rootFrame->setFrameFormat(frameFormat); //给框架使用格式
//this->setTextInteractionFlags(Qt::TextEditable);//不能选中
this->setLineWrapMode(QTextEdit::NoWrap);
for(QTextBlock textBlock = this->document()->begin();
textBlock != this->document()->end();
textBlock = textBlock.next()){
QTextBlockFormat textBlockFormat = textBlock.blockFormat();
textBlockFormat.setBottomMargin(0);
QTextCursor textCursor = this->textCursor();
textCursor.setBlockFormat(textBlockFormat);
this->setTextCursor(textCursor);
}
}
void MyTextEdit::dragEnterEvent ( QDragEnterEvent * e ){
e->ignore();
}
void MyTextEdit::dragLeaveEvent ( QDragLeaveEvent * e ){
e->ignore();
}
void MyTextEdit::dragMoveEvent ( QDragMoveEvent * e ){
e->ignore();
}
void MyTextEdit::mouseDoubleClickEvent ( QMouseEvent * e ){
e->ignore();
}
void MyTextEdit::mousePressEvent(QMouseEvent * e)
{
//获取点击的下标
//qDebug() << e->x() << ":" << e->y();
if(this->toPlainText().length()>1 && cursorForPosition(e->pos()).atEnd())
{
int textHeight=this->height();
QPoint currentPt=e->pos();
QTextCursor textCursor=cursorForPosition(currentPt);
while(textCursor.atEnd() && 0<--textHeight && 0<currentPt.y())
{
int textWidth=this->width();
currentPt.setX(e->pos().x());
currentPt.setY(currentPt.y()-5);
textCursor=cursorForPosition(currentPt);
while(textCursor.atEnd() && 0<--textWidth && 0<currentPt.x())
{
currentPt.setX(currentPt.x()-8);
textCursor=cursorForPosition(currentPt);
}
}
if(0<currentPt.x() && 0<currentPt.y())
{
currentPt.setX(e->pos().x()+8);
this->setTextCursor(cursorForPosition(currentPt));
return;
}
}
if(e->button() == Qt::LeftButton)
{
QWSServer::sendKeyEvent(0,Qt::Key_Left1,Qt::NoModifier,true,false);
QWSServer::sendKeyEvent(0,Qt::Key_Left,Qt::NoModifier,true,false); //向系统发送键盘事件
QWSServer::sendKeyEvent(0,Qt::Key_Right1,Qt::NoModifier,true,false);
QWSServer::sendKeyEvent(0,Qt::Key_Right,Qt::NoModifier,true,false);
//setCursor();
//QTextCursor textCursor = this->textCursor();
//textCursor.clearSelection();
//textCursor.setPosition(e->x());
//textCursor.setBlockFormat(textBlockFormat);
//this->setTextCursor(textCursor);
}
// if(e->button() == Qt::RightButton)
// {
// e->ignore();
// }
// else
{
QTextEdit::mousePressEvent(e);
}
}
//bool MyTextEdit::qwsEvent ( QWSEvent * event ){
//}
//void MyTextEdit::mouseMoveEvent ( QMouseEvent * e ){
// e->ignore();
//}
//
//void MyTextEdit::changeEvent ( QEvent * event ){
// if(event->type()==QEvent::FontChange)
// {
// }
// QTextEdit::changeEvent(event);
//}
//void MyTextEdit::mouseReleaseEvent(QMouseEvent * e)
//{
// QTextCursor textCursor = this->textCursor();
// textCursor.clearSelection();
// QTextEdit::mouseReleaseEvent(e);
//}