wumu
16 小时以前 8f4eb9a829d70a28c1d6dff8baa1034e57878c56
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
40
41
42
43
44
45
46
47
48
49
50
51
#include "deepseekmainwindow.h"
#include "ui_deepseekmainwindow.h"
 
#include <QGraphicsScene>
#include <qgraphicsitem.h>
#include <qgraphicsview.h>
#include <qlabel.h>
 
DeepSeekMainWindow::DeepSeekMainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DeepSeekMainWindow)
{
    ui->setupUi(this);
}
 
DeepSeekMainWindow::~DeepSeekMainWindow()
{
    delete ui;
}
 
void DeepSeekMainWindow::on_pushButton_clicked()
{
    QString htmlContent = "<div style='display: flex; justify-content: space-between;'>"
                          "<div style='float:left; text-align:left'>左侧文本</div>"
                          "<divstyle='float:right; text-align:right'>右侧文本</div>"
                          "</div>";
    ui->textBrowser->setHtml(htmlContent);
 
//    QGraphicsScene *scene = new QGraphicsScene();
//    QGraphicsTextItem *leftText = scene->addText("左侧文本");
//    QGraphicsTextItem *rightText = scene->addText("右侧文本");
//    leftText->setPos(0, 0); // 设置左侧文本的位置
//    rightText->setPos(width() - 100, 0); // 设置右侧文本的位置,根据需要调整位置和大小
//    QGraphicsView *graphicsView = new QGraphicsView(scene);
//    ui->textBrowser->setViewport(graphicsView); // 将GraphicsView设置为视口内容
 
 
//    QLabel *leftLabel = new QLabel("左侧文本");
//    QLabel *rightLabel = new QLabel("右侧文本");
 
//    QHBoxLayout *layout = new QHBoxLayout();
//    layout->addWidget(leftLabel);
//    layout->addWidget(rightLabel);
//    layout->addStretch(100); // 确保右边有足够的空间
 
//    QWidget *container = new QWidget();
//    container->setLayout(layout);
 
//    ui->textBrowser->setReadOnly(true); // 确保文本浏览器为只读模式,如果需要的话
//    ui->textBrowser->setViewport(container); // 将自定义的布局设置为视口内容
}