Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Custom Input: QLineEdit

    General and Desktop
    2
    3
    136
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      fem_dev last edited by

      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.

      0_1566330109976_input_x.jpg
      Could you help me?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Might be QLineEdit::addAction.

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        F 1 Reply Last reply Reply Quote 1
        • F
          fem_dev @SGaist last edited by

          @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);
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post