Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. setCancelButtonText not working
Forum Update on Tuesday, May 27th 2025

setCancelButtonText not working

Scheduled Pinned Locked Moved Solved General and Desktop
qinputdialog
5 Posts 3 Posters 841 Views 1 Watching
  • 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.
  • O Offline
    O Offline
    Oreonan
    wrote on 2 Feb 2021, 19:44 last edited by
    #1

    Hi,
    I've tried to change text of Cancel button in a QInputDialog, but this is not working.
    My code is:
    QInputDialog iD1;
    iD1.setCancelButtonText(tr("&Cancel"));
    m_host.username = iD1.getText(this, tr("Login error"),
    tr("Invalid user account. Type username:"),
    QLineEdit::Normal, m_host.username, &ok);
    Cancel button is still the same like default after this code.
    Do you have an idea for help me?
    Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 Feb 2021, 20:21 last edited by
      #2

      Hi and welcome to devnet,

      As stated in its documentation, getText is a static method therefore it won't make use of the instance you modified.

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

      O 1 Reply Last reply 2 Feb 2021, 20:53
      1
      • S SGaist
        2 Feb 2021, 20:21

        Hi and welcome to devnet,

        As stated in its documentation, getText is a static method therefore it won't make use of the instance you modified.

        O Offline
        O Offline
        Oreonan
        wrote on 2 Feb 2021, 20:53 last edited by
        #3

        @SGaist Thanks for your quick answer. But, in this case, I can't change name of a button and in the mean time use gettext function?
        I've read documentation but I've find nothing interesting :(

        J 1 Reply Last reply 3 Feb 2021, 06:54
        0
        • O Oreonan
          2 Feb 2021, 20:53

          @SGaist Thanks for your quick answer. But, in this case, I can't change name of a button and in the mean time use gettext function?
          I've read documentation but I've find nothing interesting :(

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 3 Feb 2021, 06:54 last edited by jsulm 2 Mar 2021, 06:55
          #4

          @Oreonan Don't use the static getText method, use your QInputDialog instance:

          QInputDialog iD1;
          iD1.setCancelButtonText(tr("&Cancel"));
          iD1.setInputMode(QInputDialog::TextInput);
          iD1.exec();
          m_host.username = iD1.textValue();
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          4
          • O Offline
            O Offline
            Oreonan
            wrote on 3 Feb 2021, 19:28 last edited by
            #5

            Thanks, it's exactly that I wanted.
            Problem is solve.

            1 Reply Last reply
            0

            1/5

            2 Feb 2021, 19:44

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved