0

我想隐藏那些边框

.

让它看起来像这样

我发现用 QT 创建一个漂亮的 GUI 非常困难,所以我想设计一个作为 PNG 背景并在其上放置一个透明对象的想法,所以我的问题是如何在 QT 中隐藏 lineEdits an Buttons 的边框

4

1 回答 1

3

一个可能的解决方案是通过属性使用 Qt Style Sheets

border-radius: some_value;

例子:

#include <QApplication>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QString qss = "QWidget{"
                       "background-color: rgb(92, 53, 102);"
                       "}"
                       "QPushButton{"
                       "border-radius: 10px;"
                       "background-color: rgb(85, 87, 83);"
                       "}"
                       "QPushButton:pressed{"
                       " border-radius: 10px;"
                       "background-color: rgb(46, 52, 54);"
                       "}"
                       "QLineEdit {"
                       "border-radius: 10px;"
                       "background-color: rgb(173, 127, 168);"
                       "}";

    a.setStyleSheet(qss);
    QWidget widget;
    widget.setLayout(new QVBoxLayout);
    widget.layout()->addWidget(new QPushButton("button"));
    widget.layout()->addWidget(new QLineEdit);
    widget.show();
    return a.exec();
}

输出:

在此处输入图像描述

参考:

于 2018-01-28T03:23:39.977 回答