logplus/WellLogUI/src/deptlineedit.cpp
2025-10-29 17:23:30 +08:00

68 lines
1.8 KiB
C++

#include "deptlineedit.h"
#include <QPaintEvent>
#include <QPainter>
#include <QStyleOptionFrameV2>
#include <QScrollBar>
#include <QGraphicsProxyWidget>
#include <QHBoxLayout>
#include <QTextCodec>
#include <QSpacerItem>
DeptLineEdit::DeptLineEdit(QWidget *parent)
: QGraphicsView(parent)
{
init();
}
DeptLineEdit::~DeptLineEdit()
{
}
void DeptLineEdit::init()
{
proxyWidget=NULL;
m_depWidget=NULL;
m_lbl=NULL;
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_depWidget=new QWidget();
m_depWidget->setFixedSize(200,35);
QHBoxLayout *hlayout=new QHBoxLayout();
lineEdit_Depth=new QLineEdit(m_depWidget);
lineEdit_Depth->setFixedSize(100,30);
lineEdit_Depth->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
lineEdit_Depth->setContentsMargins(0,0,0,0);
lineEdit_Depth->setStyleSheet("border:1px solid gray;");
m_lbl=new QLabel(m_depWidget);
m_lbl->setFixedHeight(30);
m_lbl->setText(tr("当前深度(m):"));//
hlayout->addStretch(1);
hlayout->addWidget(m_lbl,0,Qt::AlignHCenter);
hlayout->addWidget(lineEdit_Depth,1);
hlayout->addStretch(1);
hlayout->setContentsMargins(0,0,0,0);
m_lbl->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
m_depWidget->setLayout(hlayout);
m_depWidget->setContentsMargins(0,0,0,0);
m_scene=new QGraphicsScene();
this->setScene(m_scene);
}
void DeptLineEdit::showEvent(QShowEvent *)
{
m_scene->setSceneRect(rect());
m_depWidget->setFixedSize(height(),width());
proxyWidget= m_scene->addWidget(m_depWidget);
this->setContentsMargins(0,0,0,0);
proxyWidget->setContentsMargins(0,0,0,0);
QPoint point=rect().center();
//proxyWidget->translate(0,point.y()+height()/2.+1);
proxyWidget->setRotation(-90);
}