fix: 重写frame控件,增加信号,让子窗口大小跟随其变化
Description: 重写frame,让子窗口大小跟随其变化 Log: 重写frame,让子窗口大小跟随其变化 Change-Id: I72776ff6cf5245426c70cccd1960046ddca059ff
This commit is contained in:
parent
4b224d4d55
commit
5e16af0300
|
@ -28,7 +28,8 @@ HEADERS += src/mainwindow.h \
|
|||
src/textloadwidget.h \
|
||||
src/view/imageview.h \
|
||||
src/tessocrutils/tessocrutils.h \
|
||||
src/loadingwidget.h
|
||||
src/loadingwidget.h \
|
||||
src/frame.h
|
||||
|
||||
SOURCES += src/main.cpp \
|
||||
src/mainwindow.cpp \
|
||||
|
@ -40,7 +41,8 @@ SOURCES += src/main.cpp \
|
|||
src/resulttextview.cpp \
|
||||
src/view/imageview.cpp \
|
||||
src/tessocrutils/tessocrutils.cpp \
|
||||
src/loadingwidget.cpp
|
||||
src/loadingwidget.cpp \
|
||||
src/frame.cpp
|
||||
|
||||
LIBS += -llept -ltesseract\
|
||||
|
||||
|
|
13
src/frame.cpp
Normal file
13
src/frame.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include "frame.h"
|
||||
|
||||
Frame::Frame(QWidget *parent, Qt::WindowFlags f)
|
||||
: QFrame(parent, f)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Frame::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
emit sigFrameResize();
|
||||
return QFrame::resizeEvent(event);
|
||||
}
|
17
src/frame.h
Normal file
17
src/frame.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef FRAME_H
|
||||
#define FRAME_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class Frame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Frame(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
signals:
|
||||
void sigFrameResize();
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // FRAME_H
|
|
@ -1,6 +1,7 @@
|
|||
#include "mainwidget.h"
|
||||
#include "view/imageview.h"
|
||||
#include "loadingwidget.h"
|
||||
#include "frame.h"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
@ -119,7 +120,7 @@ void MainWidget::setupUi(QWidget *Widget)
|
|||
m_frameLayout->setContentsMargins(10, 10, 10, 10);
|
||||
|
||||
//后面加一层窗口,左边空间间距20
|
||||
m_frameStack = new QFrame(this);
|
||||
m_frameStack = new Frame(this);
|
||||
m_frameStack->setFrameShape(QFrame::StyledPanel);
|
||||
m_frameStack->setFrameShadow(QFrame::Raised);
|
||||
m_frameStack->setLineWidth(0);
|
||||
|
@ -146,6 +147,10 @@ void MainWidget::setupUi(QWidget *Widget)
|
|||
//宽度最大值为440
|
||||
m_frameStack->setMaximumWidth(440);
|
||||
|
||||
connect(m_frameStack, &Frame::sigFrameResize, this, [ = ] {
|
||||
m_resultWidget->resize(QSize(m_frameStack->width() - 25, m_frameStack->height()));
|
||||
});
|
||||
|
||||
|
||||
m_loadingOcr = new loadingWidget(this);
|
||||
m_loadingOcr->setAlignment(Qt::AlignCenter);
|
||||
|
@ -294,8 +299,8 @@ void MainWidget::deleteLoadingUi()
|
|||
|
||||
void MainWidget::loadingUi()
|
||||
{
|
||||
if (m_loadingWidget && m_loadingTip && m_resultWidget) {
|
||||
int x = this->width() - m_resultWidget->width() / 2;
|
||||
if (m_loadingWidget && m_loadingTip && m_frameStack) {
|
||||
int x = this->width() - m_frameStack->width() / 2;
|
||||
int y = this->height() / 2 - 50;
|
||||
qDebug() << m_loadingWidget->width();
|
||||
m_loadingWidget->setFixedSize(QSize(24, 24));
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
#include <DToolButton>
|
||||
|
||||
#include "resulttextview.h"
|
||||
|
||||
#include "textloadwidget.h"
|
||||
#include "tessocrutils/tessocrutils.h"
|
||||
|
||||
class Frame;
|
||||
class QThread;
|
||||
class QGridLayout;
|
||||
class QHBoxLayout;
|
||||
|
@ -77,7 +79,7 @@ private:
|
|||
QFrame *m_frame{nullptr};
|
||||
|
||||
QHBoxLayout *m_frameStackLayout{nullptr};
|
||||
QFrame *m_frameStack{nullptr};
|
||||
Frame *m_frameStack{nullptr};
|
||||
|
||||
DLabel *m_tipIconLabel{nullptr};
|
||||
DHorizontalLine *m_line{nullptr};
|
||||
|
|
Loading…
Reference in New Issue
Block a user