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. Latest Qt, ubuntu, C++ based app, could not using arrows and scroll
Forum Updated to NodeBB v4.3 + New Features

Latest Qt, ubuntu, C++ based app, could not using arrows and scroll

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 977 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.
  • J JacobNovitsky

    if using arrows or scroll getting special symbols
    ^[[A^[[A^[[A^A
    how to fix it?

    if using Ubuntu terminal it gets previous command well

    JonBJ Online
    JonBJ Online
    JonB
    wrote on last edited by
    #2

    @JacobNovitsky
    A shell running in a terminal does the "previous command" stuff, nothing inherent about keys. There is nothing to "fix". You have to explain where you are pressing arrow keys in a program.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JacobNovitsky
      wrote on last edited by
      #3

      sorry, its terminal :)

      JonBJ 1 Reply Last reply
      0
      • J JacobNovitsky

        sorry, its terminal :)

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by
        #4

        @JacobNovitsky
        You have written a terminal with Qt and C++?
        Or you are using one written by a third-party?

        J 1 Reply Last reply
        0
        • JonBJ JonB

          @JacobNovitsky
          You have written a terminal with Qt and C++?
          Or you are using one written by a third-party?

          J Offline
          J Offline
          JacobNovitsky
          wrote on last edited by JacobNovitsky
          #5

          @JonB its qt creator output terminal in Ubuntu environment
          terminal.png
          if i call terminal with shortcut Ctrl T or just open app it works
          f i call terminal from Qt creator it wont

          jsulmJ JonBJ 2 Replies Last reply
          0
          • J JacobNovitsky

            @JonB its qt creator output terminal in Ubuntu environment
            terminal.png
            if i call terminal with shortcut Ctrl T or just open app it works
            f i call terminal from Qt creator it wont

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #6

            @JacobNovitsky said in Latest Qt, ubuntu, C++ based app, could not using arrows and scroll:

            f i call terminal from Qt creator it wont

            Please show the code where you're opening the terminal...
            And I guess after opening the terminal from your app there are no "previous" commands yet.

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

            1 Reply Last reply
            1
            • J JacobNovitsky

              @JonB its qt creator output terminal in Ubuntu environment
              terminal.png
              if i call terminal with shortcut Ctrl T or just open app it works
              f i call terminal from Qt creator it wont

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by JonB
              #7

              @JacobNovitsky said in Latest Qt, ubuntu, C++ based app, could not using arrows and scroll:

              @JonB its qt creator output terminal in Ubuntu environment

              I assume this means the option in Creator which says something like "Run a terminal".

              If so, you are not understanding that this is not the same as some "Terminal" program from the OS:

              • The OS opens a terminal running a shell (e.g. bash) for you. That shell reads what you type, runs commands for you, allows output. It interprets the arrows as going through the history and implements that.
              • Creator's "Run in terminal" option purely allows your Qt program to have a terminal window for input/output. It does not run some shell there. There is no history of commands to go through.

              If you want an actual terminal running a shell from a Qt application, not just for plain I/O, you will need your program to use QProcess to spawn a suitable terminal with a shell, such as xterm or whatever your Terminal is.

              J 1 Reply Last reply
              1
              • JonBJ JonB

                @JacobNovitsky said in Latest Qt, ubuntu, C++ based app, could not using arrows and scroll:

                @JonB its qt creator output terminal in Ubuntu environment

                I assume this means the option in Creator which says something like "Run a terminal".

                If so, you are not understanding that this is not the same as some "Terminal" program from the OS:

                • The OS opens a terminal running a shell (e.g. bash) for you. That shell reads what you type, runs commands for you, allows output. It interprets the arrows as going through the history and implements that.
                • Creator's "Run in terminal" option purely allows your Qt program to have a terminal window for input/output. It does not run some shell there. There is no history of commands to go through.

                If you want an actual terminal running a shell from a Qt application, not just for plain I/O, you will need your program to use QProcess to spawn a suitable terminal with a shell, such as xterm or whatever your Terminal is.

                J Offline
                J Offline
                JacobNovitsky
                wrote on last edited by JacobNovitsky
                #8

                @JonB now the thing is more clear :)
                can u share the code, please?

                having this, and this yet does nothing

                #include <QCoreApplication>
                #include <QProcess>
                int main()
                {
                while(true){
                    QProcess process;
                    process.start("ls");
                    process.waitForFinished();
                
                    QString output = process.readAllStandardOutput();
                    qDebug() << output;
                    }
                
                    return 0;
                }
                
                JonBJ 1 Reply Last reply
                0
                • J JacobNovitsky

                  @JonB now the thing is more clear :)
                  can u share the code, please?

                  having this, and this yet does nothing

                  #include <QCoreApplication>
                  #include <QProcess>
                  int main()
                  {
                  while(true){
                      QProcess process;
                      process.start("ls");
                      process.waitForFinished();
                  
                      QString output = process.readAllStandardOutput();
                      qDebug() << output;
                      }
                  
                      return 0;
                  }
                  
                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by JonB
                  #9

                  @JacobNovitsky
                  I don't think QProcess::waitForFinished() will return since you do not have the Qt event loop running. (Put qDebug()s in to see which line is being reached.) Get rid of while and write it as a proper Qt program.

                  J 1 Reply Last reply
                  1
                  • JonBJ JonB

                    @JacobNovitsky
                    I don't think QProcess::waitForFinished() will return since you do not have the Qt event loop running. (Put qDebug()s in to see which line is being reached.) Get rid of while and write it as a proper Qt program.

                    J Offline
                    J Offline
                    JacobNovitsky
                    wrote on last edited by
                    #10

                    @JonB After two years with Qt as IDE I'm really stuck now
                    can you please provide working sample, to make the terminal in Ubuntu work smoothly like in Windows?

                    jsulmJ 1 Reply Last reply
                    0
                    • J JacobNovitsky

                      @JonB After two years with Qt as IDE I'm really stuck now
                      can you please provide working sample, to make the terminal in Ubuntu work smoothly like in Windows?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @JacobNovitsky said in Latest Qt, ubuntu, C++ based app, could not using arrows and scroll:

                      Qt as IDE

                      Qt isn't an IDE.
                      As @JonB pointed out you need running Qt event loop to be able to use signals/slots. This is very basic Qt.
                      To start Qt event loop you need to call https://doc.qt.io/qt-6/qapplication.html#exec like in any proper Qt application. See https://doc.qt.io/qt-6/qapplication.html for an example.

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

                      1 Reply Last reply
                      2

                      • Login

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