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 Updated to NodeBB v4.3 + New Features

setCancelButtonText not working

Scheduled Pinned Locked Moved Solved General and Desktop
qinputdialog
5 Posts 3 Posters 859 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 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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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
      1
      • SGaistS SGaist

        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 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 :(

        jsulmJ 1 Reply Last reply
        0
        • O Oreonan

          @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 :(

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #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 last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

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