How to place an icon onto a QLineEdit?

后端 未结 7 920
终归单人心
终归单人心 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条回答
  •  -上瘾入骨i
    2021-02-08 07:35

    From QT 5.2 onwards you can do something like this. You should use pointers if you want to make it more flexible:

    
    QIcon *ico;
    ico = new QIcon(":/images/search.ico");
    searchEdit->addAction(*ico, QLineEdit::LeadingPosition);
    
    

提交回复
热议问题