#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QHBoxLayout>
#include <QFileDialog>
#include <QButtonGroup>
#include <QStylePainter>
#include <QAbstractButton>
#include <QStyleFactory>
#include <QHeaderView>
#include <QStandardItemModel>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWidget *p = takeCentralWidget();
if (p){
delete p;
}
setDockNestingEnabled(true); //允许嵌套dockeidget
m_docks.append(ui->dockWidget_1); //记录所有dock的指针
m_docks.append(ui->dockWidget_2);
m_docks.append(ui->dockWidget_3);
m_docks.append(ui->dockWidget_4);
m_docks.append(ui->dockWidget_5);
m_docks.append(ui->dockWidget_6);
m_docks.append(ui->dockWidget_7);
m_docks.append(ui->dockWidget_8);
m_docks.append(ui->dockWidget_9);
m_docks.append(ui->dockWidget_10);
QProgressBar *pProgressBar3 = ui->progressBar;
pProgressBar3->setOrientation(Qt::Horizontal); // 水平方向
pProgressBar3->setMinimum(0); // 最小值R
pProgressBar3->setMaximum(4800); // 最大值
pProgressBar3->setValue(2000); // 当前进度
double dProgress = (pProgressBar3->value() - pProgressBar3->minimum()) * 100.0
/ (pProgressBar3->maximum() - pProgressBar3->minimum());
//fromLocal8Bit:它将一个本地编码的QByteArray对象转换为一个QString对象
//QString::number(dProgress, 'f', 1):显示fload类型,保留1位小数。将替换掉前方的 %1
pProgressBar3->setFormat(QString::fromLocal8Bit("Current is:%1%").arg(QString::number(dProgress, 'f', 1)));
pProgressBar3->setAlignment(Qt::AlignRight | Qt::AlignVCenter); // 对齐方式
connect(ui->Btn_InputSGY,&QPushButton::clicked,this,[=]{
//执行文件对话框
QFileDialog filedlg;
ui->Line_InputSGY->setText( filedlg.getOpenFileName(this,tr("Open File"),"./","Any files (*);;Image files (*.png *.jpg);;Text Files (*.txt)"));
if (ui->Line_InputSGY->text()!=""){
ui->lineEdit_8->setEnabled(true);
ui->lineEdit_9->setEnabled(true);
ui->lineEdit_10->setEnabled(true);
ui->lineEdit_11->setEnabled(true);
}
});
QButtonGroup *pBtnG = new QButtonGroup();
pBtnG->addButton(ui->Radio_2D);
pBtnG->addButton(ui->Radio_3D);
ui->Radio_2D->setChecked(true); //为radio组设置初选项
ui->tableWidget_3->setRowCount(13);
ui->tableWidget_3->setColumnCount(4);
ui->tableWidget_3->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableWidget_3->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableWidget_3->setStyleSheet("QHeaderView::section{" //设置表3样式
"border-top:0px solid #00FF00;"
"border-left:0px solid #00FF00;"
"border-right:0px solid #00FF00;"
"border-bottom: 0px solid #00FF00;"
"background-color:white;"
"padding:0px;"
"}"
);
ui->tableWidget_2->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //自适应可伸缩
ui->tableWidget_2->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
setTableWidgetData();
splitDockWidget(ui->dockWidget_1,ui->dockWidget_2,Qt::Vertical);
splitDockWidget(ui->dockWidget_2,ui->dockWidget_3,Qt::Vertical);
splitDockWidget(ui->dockWidget_3,ui->dockWidget_4,Qt::Horizontal);
splitDockWidget(ui->dockWidget_4,ui->dockWidget_5,Qt::Horizontal);
splitDockWidget(ui->dockWidget_5,ui->dockWidget_6,Qt::Horizontal);
splitDockWidget(ui->dockWidget_3,ui->dockWidget_7,Qt::Vertical);
splitDockWidget(ui->dockWidget_4,ui->dockWidget_8,Qt::Vertical);
splitDockWidget(ui->dockWidget_5,ui->dockWidget_9,Qt::Vertical);
splitDockWidget(ui->dockWidget_6,ui->dockWidget_10,Qt::Vertical);
DeleteDockTitleLine();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::removeAllDock() // 会把所有dock隐藏
{
for (auto i: m_docks){
removeDockWidget(i);
}
}
/*
* 显示指定需要的dock
* index: 指定序号, 如果不指定, 则会显示所有
*/
void MainWindow::showDock(const QList<int> &index)
{
if ( index.isEmpty()){
for (int i = 0; i < m_docks.count(); ++i){
m_docks[i]->show();
}
}else{
foreach (int i, index) {
m_docks[i]->show();
}
}
}
void MainWindow::LayoutDockWidget()
{
}
void MainWindow::DeleteTitleLine(QDockWidget *pDock)
{
QWidget *pw1 = new QWidget();
delete pDock->titleBarWidget();
pDock->setTitleBarWidget(pw1);
}
void MainWindow::DeleteDockTitleLine()
{
DeleteTitleLine(ui->dockWidget_1);
DeleteTitleLine(ui->dockWidget_2);
DeleteTitleLine(ui->dockWidget_3);
DeleteTitleLine(ui->dockWidget_4);
DeleteTitleLine(ui->dockWidget_5);
DeleteTitleLine(ui->dockWidget_6);
DeleteTitleLine(ui->dockWidget_7);
DeleteTitleLine(ui->dockWidget_8);
DeleteTitleLine(ui->dockWidget_9);
DeleteTitleLine(ui->dockWidget_10);
}
void MainWindow::setTableWidgetData()
{
for ( int i= 0; i < ui->tableWidget_3->rowCount(); ++i){
ui->tableWidget_3->verticalHeaderItem(i)->setTextAlignment( Qt::AlignRight ); //列标题文字居中
QSpinBox *pSpinBox = new QSpinBox();
pSpinBox->setValue(0);
ui->tableWidget_3->setCellWidget(i,0,pSpinBox);
QComboBox *pCombox = new QComboBox();
pCombox->addItem(tr("32bit"));
pCombox->addItem(tr("16bit"));
ui->tableWidget_3->setCellWidget(i,1,pCombox);
QLineEdit *pLineEdit = new QLineEdit();
pLineEdit->setText("0");
ui->tableWidget_3->setCellWidget(i,2,pLineEdit);
QCheckBox * checkB = new QCheckBox(ui->tableWidget_3); //创建checkbox
QWidget *w = new QWidget(ui->tableWidget_3); //创建一个widget
QHBoxLayout *hLayout = new QHBoxLayout(); //创建布局
hLayout->addWidget(checkB); //添加checkbox
hLayout->setContentsMargins(0,0,0,0);
hLayout->setAlignment(checkB, Qt::AlignCenter); //居中
w->setLayout(hLayout); //设置widget的布局
ui->tableWidget_3->setCellWidget(i, 3, w); //将widget放到table中
}
for ( int i = 0; i < ui->tableWidget->columnCount();++i){
// 先这样,后期开启策略
if (i == 0){
QWidget *pWidget1 = new QWidget();
QVBoxLayout *pVB1 = new QVBoxLayout();
pVB1->setContentsMargins(0,0,0,0);
pWidget1->setLayout(pVB1);
QLabel *pLab1 = new QLabel("Trance number");
pLab1->setAlignment(Qt::AlignCenter);
pVB1->addWidget(pLab1);
ui->tableWidget->setCellWidget(0,i,pWidget1);
}
else
{
QLabel *pLab2 = new QLabel("trc seq\n in line\n 1 - 4");
pLab2->setAlignment(Qt::AlignCenter);
QComboBox *pCB2 = new QComboBox();
pCB2->addItem("Line Header");
QWidget *pWidget2 = new QWidget();
QVBoxLayout *pVB2 = new QVBoxLayout();
pVB2->setContentsMargins(0,0,0,0);
pVB2->addWidget(pLab2);
J_admin
- 粉丝: 192
- 资源: 4
最新资源
- 题目源码2024年强网杯全国网络安全挑战赛 PWN题目baby-heap源码
- 题目源码2024年强网杯全国网络安全挑战赛 PWN题目expect-number源码
- 省份劳动率最终.dta
- 题目源码2024年强网杯全国网络安全挑战赛 PWN题目prpr源码
- Rust Trait 静态派发与动态派发示例
- 拼多多官方_main_main_baidu_sem_dz1_ARM64.apk
- 小米机型小米助手界面检测当前机型 包括 Android 版本、MIUI 版本和固件详细信息
- share6620081042528496742.jpg
- 21英语210405010143罗杰_周霜红 文献综述.doc
- share6329583338574047795.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈