I'm trying to create a custom shape QLineEdit
with QWidget::setMask()
. I redefined resizeEvent
for my sub class lineEdit
.
void MyLineEdit::resizeEvent(QResizeEvent *ev)
{
QPixmap pixmap(":/new/prefix1/region.png");
setFixedSize(ev->size());
setMask(pixmap.mask());
setStyleSheet("background-color : gray");
}
But the QlineEdit
isn't showed. Btw, it was added to a QGridlayout
and I checked that pixmap.isNull() == false
and the size was normal.
Did I miss something? Why isn't it displayed?
You don't have to subclass anything. Just use style sheets.
editor->setStyleSheet("QLineEdit {\n"
" background: url(:/new/prefix1/region.png);\n"
"}");
editor->setStyleSheet("QLineEdit {\n"
" border-image: url(:/new/prefix1/region.png) 3 3 3 3;\n"
"}");