我想隐藏那些边框
.
让它看起来像这样
我发现用 QT 创建一个漂亮的 GUI 非常困难,所以我想设计一个 PNG 背景并在其上放置一个透明对象,所以我的问题是如何隐藏 lineEdits 和QT中的按钮
最佳答案
一个可能的解决方案是通过属性使用 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();
}
输出:
引用资料:
关于c++ - 隐藏 QPushButton 和 QLineEdit 边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48482500/