Important: Please read the Qt Code of Conduct -

Custom Input: QLineEdit

  • Looking inside Qt Creator IDE -> Tools -> Options -> Build & Run -> General Tab:
    There is a "Default build directory" input field.

    When I click inside this field, it shows me a "AB" icon on the right side.
    And if I click in this icon, I got a list window with some options...

    I would like to know how can I implement this QLineEdit component with this "right icon" feature.

    Could you help me?

  • Lifetime Qt Champion


    Might be QLineEdit::addAction.

    Otherwise, you can take a look at Qt Creator's sources for that field.

  • @sgaist that's right! Thank you!

    QLineEdit *myLineEdit = new QLineEdit(this);
    QAction *myAction = myLineEdit->addAction(QIcon("test.png"), QLineEdit::TrailingPosition);
    connect(myAction, &QAction::triggered, this, &MyClass::onActionTriggered);

Log in to reply