How to place an icon onto a QLineEdit?

后端 未结 7 918
终归单人心
终归单人心 2021-02-08 07:09

There is a Search field with the magnification-lens and a greyed out \"search\" keyword at the top right corner of stackoverflow.com web site:

7条回答
  •  遥遥无期
    2021-02-08 07:46

    QLineEdit* _lineEdit = new QLineEdit();
    _lineEdit->setClearButtonEnabled(true);
    _lineEdit->addAction(":/resources/search.ico", QLineEdit::LeadingPosition);
    _lineEdit->setPlaceHolderText("Search...");
    

    extracted from: http://saurabhg.com/programming/search-box-using-qlineedit/

提交回复
热议问题