feat: 添加无识别结果提示
添加无识别结果提示 Log: 识别结果展示相关 Change-Id: I74847ee2847175b8de0f6ec49a0a086cb1cdacc3
This commit is contained in:
parent
affb98dccf
commit
dabea64329
|
@ -107,11 +107,22 @@ void MainWidget::setupUi(QWidget *Widget)
|
|||
if (!m_imageview) {
|
||||
m_imageview = new ImageView();
|
||||
}
|
||||
|
||||
m_resultWidget = new QStackedWidget(this);
|
||||
m_resultWidget->setFocusPolicy(Qt::NoFocus);
|
||||
m_resultWidget->addWidget(m_plainTextEdit);
|
||||
|
||||
m_noResult = new DLabel(this);
|
||||
m_noResult->setAlignment(Qt::AlignCenter);
|
||||
m_noResult->setText(tr("No text recognized"));
|
||||
|
||||
m_resultWidget->addWidget(m_noResult);
|
||||
|
||||
QSplitter *mainSplitter = new QSplitter(Qt::Horizontal); //新建水平分割器
|
||||
mainSplitter->setHandleWidth(1);//分割线的宽度
|
||||
mainSplitter->setChildrenCollapsible(false);//不允许把分割出的子窗口拖小到0,最小值被限定为sizeHint或maxSize/minSize
|
||||
mainSplitter->addWidget(m_imageview);//把ui中拖出的各个控件拿走,放到分割器里面
|
||||
mainSplitter->addWidget(m_plainTextEdit);
|
||||
mainSplitter->addWidget(m_resultWidget);
|
||||
QList<int> list;
|
||||
list << 600 << 250;
|
||||
mainSplitter->setSizes(list);
|
||||
|
@ -287,17 +298,28 @@ void MainWidget::openImage(const QImage &img)
|
|||
void MainWidget::loadHtml(const QString &html)
|
||||
{
|
||||
if (!html.isEmpty()) {
|
||||
m_resultWidget->setCurrentWidget(m_plainTextEdit);
|
||||
m_plainTextEdit->appendHtml(html);
|
||||
} else {
|
||||
resultEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::loadString(const QString &string)
|
||||
{
|
||||
if (!string.isEmpty()) {
|
||||
m_resultWidget->setCurrentWidget(m_plainTextEdit);
|
||||
m_plainTextEdit->appendPlainText(string);
|
||||
} else {
|
||||
resultEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::resultEmpty()
|
||||
{
|
||||
m_resultWidget->setCurrentWidget(m_noResult);
|
||||
}
|
||||
|
||||
void MainWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
return DWidget::resizeEvent(event);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <DGuiApplicationHelper>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QStackedWidget>
|
||||
|
||||
#include "resulttextview.h"
|
||||
#include "textloadwidget.h"
|
||||
|
@ -42,6 +43,7 @@ public:
|
|||
|
||||
void loadHtml(const QString &html);
|
||||
void loadString(const QString &string);
|
||||
void resultEmpty();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
@ -75,6 +77,9 @@ private:
|
|||
QMutex m_mutex;
|
||||
RecognitionResult m_result;
|
||||
QImage *m_currentImg{nullptr};
|
||||
|
||||
QStackedWidget *m_resultWidget{nullptr};
|
||||
DLabel *m_noResult{nullptr};
|
||||
signals:
|
||||
void sigResult(const QString &);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user