[Solved]QLineEdit Rounded Corners?
-
Is there a way to round the corners of a QLineEdit widget? If not is there a similar widget I could do this to?
!http://www.themindspot.com/junk/images/shape.jpg(Demonstration)!Update Answer:
@ QLineEdit *lineEdit = new QLineEdit;lineEdit -> setStyleSheet("QLineEdit { border: 2px solid gray;" "border-radius: 5px;}");@
Brandon Clark
-
You can use Style Sheets.
call setStyleSheet , or set it in designer.
for example this style:
"background-color: red; border-radius: 10px; padding: 10px;"here more examples:
http://doc.trolltech.com/4.3/stylesheet-examples.html
Here docs:
http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html -
Learn about QSS (Qt Style Sheets) - it allows to add CSS styling to your Qt application.
file.cpp
@
QWidget * widget = new QWidget(this);
QFile css(":/qss/main.qss");
if(css.open(QIODevice::ReadOnly)) {
widget->setStyleSheet(css.readAll());
}
@main.qss
@
QLineEdit {
border-radius: 30px;
}
@In QSS file can be allocated any CSS2 rules and most of CSS3 rules.