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. Emulating command console
Qt 6.11 is out! See what's new in the release blog

Emulating command console

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 4.9k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I want it to be like the windows cmd, you write a command and then it gives back information but you cant edit what already is writed, you can only edit the text that you are introducing for the next command and i dont know how to do that. Well thanks and any idea is welcome!

    -Noele1995

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      Create a new QDialog, insert a Vertical Layout and then put a QPlainTextEdit on top plus a QLineEdit on the bottom. Make the QPlainTextEdit read-only.

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Seamus Boyle
        wrote on last edited by
        #3

        Subclass QPlainTextEdit or QTextEdit and handle key press events yourself; up key for command history, enter for line execute, and so on.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          That was my first option but i dont really know how to do that.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MuldeR
            wrote on last edited by
            #5

            [quote author="Seamus Boyle" date="1377418770"]Subclass QPlainTextEdit or QTextEdit and handle key press events yourself; up key for command history, enter for line execute, and so on.[/quote]

            Should not be required, I think.

            Just connect a signal to QLineEdit::retrunPressed(). This will tell you when the user has typed a new command into the LineEdit. Then just do whatever needs to be done and append the desired output (logging) into the QPlainTextEdit. For details see "Signals and Slots":http://qt-project.org/doc/qt-4.8/signalsandslots.html

            My OpenSource software at: http://muldersoft.com/

            Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

            Go visit the coop: http://youtu.be/Jay...

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Yes i know to do that, actually thats what i did, but i wanted that window to look like it had a console inside of it but it woked fine.

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                How can i make in the QLineEdit that if i prees up arrow it shows me the last command i wrote there?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MuldeR
                  wrote on last edited by
                  #8

                  Have a look at QLineEdit::setCompleter() and at QCompleter.

                  @QStringList wordList;
                  wordList << "alpha" << "omega" << "omicron" << "zeta";

                  QLineEdit *lineEdit = new QLineEdit(this);

                  QCompleter *completer = new QCompleter(wordList, this);
                  completer->setCaseSensitivity(Qt::CaseInsensitive);
                  lineEdit->setCompleter(completer);@

                  The "wordList" would simply be the list of recently used commands.

                  --

                  Also check the available QCompleter::CompletionMode values!

                  My OpenSource software at: http://muldersoft.com/

                  Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

                  Go visit the coop: http://youtu.be/Jay...

                  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