行文本形式如下
<<word 文档标题>> [word 文档路径] 段落序号
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| void DzfContentEdit::mouseMoveEvent(QMouseEvent *e) { QTextEdit::mouseMoveEvent(e);
auto pos = e->pos(); auto cursor = cursorForPosition(pos); cursor.select(QTextCursor::LineUnderCursor); auto line = cursor.selectedText();
QRegExp reg("\\[(.*docx?)\\]"); if(reg.indexIn(line) != -1){ doc_ = reg.capturedTexts().at(1);
viewport()->setCursor(Qt::PointingHandCursor); }else{ doc_.clear();
viewport()->setCursor(Qt::IBeamCursor); } }
void DzfContentEdit::mouseDoubleClickEvent(QMouseEvent *e) { if(!doc_.isEmpty()){ doc_.prepend("file:///");
QDesktopServices::openUrl(QUrl(doc_)); }else{ QTextEdit::mouseDoubleClickEvent(e); } }
|