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. QInputDialog::setInputMode doesn't work

QInputDialog::setInputMode doesn't work

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 338 Views
  • 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.
  • S Offline
    S Offline
    Sucharek
    wrote on last edited by Sucharek
    #1

    Hi, I've been trying to set up QInputDialog::setInputMode, but I can't seem to get it to work. Here's what I tried:

    QInputDialog getCustomText;
    getCustomText.setInputMode(QInputDialog::InputMode (QInputDialog::UsePlainTextEditForTextInput));
    qDebug() << getCustomText.inputMode(); //prints 0
    if (getCustomText.exec() == QInputDialog::Accepted) {
        ...
    }
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Because QInputDialog::UsePlainTextEditForTextInput is an InputDialogOption, not an InputMode

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      S 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Because QInputDialog::UsePlainTextEditForTextInput is an InputDialogOption, not an InputMode

        S Offline
        S Offline
        Sucharek
        wrote on last edited by
        #3

        Hi @Christian-Ehrlicher, oh ok, but there are only 3 options, not including textEdit. Can I have QTextEdit instead of QLineEdit?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Use the setOption method.

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

          S 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            Use the setOption method.

            S Offline
            S Offline
            Sucharek
            wrote on last edited by
            #5

            Hi @SGaist, thank you, that is what I was looking for. It works perfectly. Code:

            QString text;
            QInputDialog getCustomText;
            getCustomText.setOption(QInputDialog::UsePlainTextEditForTextInput);
            getCustomText.setWindowTitle("Set a custom course");
            getCustomText.setLabelText("Type in or paste an article.");
            if (getCustomText.exec() == QInputDialog::Accepted) {
                text = getCustomText.textValue();
            }
            
            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