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. QProcess running "xterm" - how to read / write directly to "xterm"
Forum Updated to NodeBB v4.3 + New Features

QProcess running "xterm" - how to read / write directly to "xterm"

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 4 Posters 1.7k 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.
  • D DerReisende

    @AnneRanch This may be OT but maybe QTermWidget might be an option for you to execute programs and get the output control you need.

    A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #8

    @DerReisende I did look into QTermWigfet and its "derivative " qterminal. As far as i can tell they are rather typical "build something on shaky foundation, because it is cool..." - I do tell how I feel and do not care if the public gets offended. For example "qterminal" cannot handle multiple arguments options. Their latest githnub notes are full of "corrected argument passing ..."

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Anonymous_Banned275
      wrote on last edited by
      #9

      Thanks for all the comments. I was not aware of -info option - it looks promising.
      I would like to stress - I an trying to resolve TWO issues - communicating with "bluetootctl" and embedding any terminal application in QTabWidget.
      I have the communication part under control...

      To embed "terminal" in QTabWidget it has to be widget.

      The example referenced does exactly that - creates a widget based dialog - that should work...

      What got me going wrong direction - at one point the "window" created by QProcess had a default icons and title of my entire application - that tells me it has to be something compatible with widget or QT object - but I was unable to find what it is and how it fits n my application hierarchy.... so I called it "top floating window ". ( I think QProcess doc may have something about the actual GUI it builds ...)

      JonBJ 1 Reply Last reply
      0
      • A Anonymous_Banned275

        Thanks for all the comments. I was not aware of -info option - it looks promising.
        I would like to stress - I an trying to resolve TWO issues - communicating with "bluetootctl" and embedding any terminal application in QTabWidget.
        I have the communication part under control...

        To embed "terminal" in QTabWidget it has to be widget.

        The example referenced does exactly that - creates a widget based dialog - that should work...

        What got me going wrong direction - at one point the "window" created by QProcess had a default icons and title of my entire application - that tells me it has to be something compatible with widget or QT object - but I was unable to find what it is and how it fits n my application hierarchy.... so I called it "top floating window ". ( I think QProcess doc may have something about the actual GUI it builds ...)

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #10

        @AnneRanch
        Honestly, QProcess does not build any GUI. It knows nothing about widgets, windows or anything UI. It just runs an external program.

        You can either embed a visual terminal and then your code cannot interact with a spawned bluetoothctl program, or you can send/receive i/o to/from it via stdin/out and no visual terminal, but not both. So long as you keep the embedded terminal and the communicating with bluetoothctl as separate things that is OK.

        1 Reply Last reply
        1
        • A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #11

          This is embarrassing, but I am stomped - again.
          I have solved the embedded issue - with simple dialog etc.

          I have been using QTABWidget and never had this issue - switching tabs does not stop showing the previous tab
          Apparently I am missing a step ....especially when the tab contains a dialog. (Why ?)

          I found this "slot" on_tabWidget_26_tabCloseRequested(int index) but cannot find anything on how and why to use it .
          I really do not want to "close" tab anyway- just switch to another one.

                                  switch(index)
                      {
                      case 0:
                      {
          
                          Form_TERM_Dialog *FTD = new Form_TERM_Dialog();
                          FTD->show();
          
                      break;
                      }
                       case 1:
                      {
                          Form_TERM_Dialog *FTD = new Form_TERM_Dialog();
                                 FTD->show();
          
                      break;
                      }
                       case 2:
                      {
                          Form_TERM_Dialog *FTD = new Form_TERM_Dialog();
                                 FTD->show();
          
                      break;
                      }
                      }
          
          JonBJ 1 Reply Last reply
          0
          • A Anonymous_Banned275

            This is embarrassing, but I am stomped - again.
            I have solved the embedded issue - with simple dialog etc.

            I have been using QTABWidget and never had this issue - switching tabs does not stop showing the previous tab
            Apparently I am missing a step ....especially when the tab contains a dialog. (Why ?)

            I found this "slot" on_tabWidget_26_tabCloseRequested(int index) but cannot find anything on how and why to use it .
            I really do not want to "close" tab anyway- just switch to another one.

                                    switch(index)
                        {
                        case 0:
                        {
            
                            Form_TERM_Dialog *FTD = new Form_TERM_Dialog();
                            FTD->show();
            
                        break;
                        }
                         case 1:
                        {
                            Form_TERM_Dialog *FTD = new Form_TERM_Dialog();
                                   FTD->show();
            
                        break;
                        }
                         case 2:
                        {
                            Form_TERM_Dialog *FTD = new Form_TERM_Dialog();
                                   FTD->show();
            
                        break;
                        }
                        }
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #12

            @AnneRanch
            QDialogs --- assuming that is what your Form_TERM_Dialog is --- cannot/should not be shown in tabs. From the docs:

            A dialog window is a top-level window mostly used for short-term tasks and brief communications with the user.

            So I don't know what you have meant by "the tab contains a dialog". If you mean the code you show is executed on changing tab, then it creates and shows a quite separate dialog window. Switching to another tab would not in any way close or affect any dialog created from code on switching to a tab previously.

            This might be what you mean by "switching tabs does not stop showing the previous tab" --- it won't affect showing a previously opened dialog.

            If --- and I don't whether it is --- your goal is to be able to close these previously opened dialogs from code (as opposed to the user clicking its close box) you will need to store your Form_TERM_Dialog *FTD somewhere else than in a local variable, so that you can access it at a later time.

            A 1 Reply Last reply
            1
            • JonBJ JonB

              @AnneRanch
              QDialogs --- assuming that is what your Form_TERM_Dialog is --- cannot/should not be shown in tabs. From the docs:

              A dialog window is a top-level window mostly used for short-term tasks and brief communications with the user.

              So I don't know what you have meant by "the tab contains a dialog". If you mean the code you show is executed on changing tab, then it creates and shows a quite separate dialog window. Switching to another tab would not in any way close or affect any dialog created from code on switching to a tab previously.

              This might be what you mean by "switching tabs does not stop showing the previous tab" --- it won't affect showing a previously opened dialog.

              If --- and I don't whether it is --- your goal is to be able to close these previously opened dialogs from code (as opposed to the user clicking its close box) you will need to store your Form_TERM_Dialog *FTD somewhere else than in a local variable, so that you can access it at a later time.

              A Offline
              A Offline
              Anonymous_Banned275
              wrote on last edited by
              #13

              @JonB I hope I can clear or restate what is happening

              1. My primary user interface is QTabWidget - lets leave the details out of the discussion.
              2. To add QProcess into the tab - it has to be a widget - hence dialog .
                That part works but the link between tab and its dialog is not clear.
                That is not why I added the dialog .
                It still looks as an "dependent ", but real dialog and top floating
                So - the tab code can create / build the dialog BUT it is NOT part of the QTabWidget - since switching tabs DOES not affect that.

              It is relatively irrelevant what to call this setup - it does not do the task indeed.
              Back to the drawing board....

              PS I am going back to the "pop-up" dialog - already forgot the name ....

              JonBJ 1 Reply Last reply
              0
              • A Anonymous_Banned275

                @JonB I hope I can clear or restate what is happening

                1. My primary user interface is QTabWidget - lets leave the details out of the discussion.
                2. To add QProcess into the tab - it has to be a widget - hence dialog .
                  That part works but the link between tab and its dialog is not clear.
                  That is not why I added the dialog .
                  It still looks as an "dependent ", but real dialog and top floating
                  So - the tab code can create / build the dialog BUT it is NOT part of the QTabWidget - since switching tabs DOES not affect that.

                It is relatively irrelevant what to call this setup - it does not do the task indeed.
                Back to the drawing board....

                PS I am going back to the "pop-up" dialog - already forgot the name ....

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #14

                @AnneRanch said in QProcess running "xterm" - how to read / write directly to "xterm":

                To add QProcess into the tab - it has to be a widget - hence dialog .

                A QTabWidget accepts QWidgets as the "pages". The example I referred you to for an embedded terminal, for instance, uses a QWidget. A QDialog is not suitable for a tab widget page, as already pointed out it is designed to be a top-level widget, not a child in a tab widget.

                From what I can see of the code you showed you are not adding a widget or dialog to the tab widget. You are opening an unrelated, separate dialog each time.

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on last edited by Anonymous_Banned275
                  #15

                  Partial success , but still not home free...
                  I have made a major mistake NOT specificity the "parent " of the test widget.
                  After correcting that I can see the test label ( from test widget) in proper "page" and I switch the tabs / pages - no problem.

                  I assumed that the QProcess should also use the passed parent.
                  That does not have expected result - being able to close the page and open another one.
                  In other words - attaching the QProcess (display) to same parent instantiate the QProcess but cannot be closed /
                  switched as part of the TAB widget fynction .

                  On top of that - I am having a real difficult time to debug / step thru the code - it seems that GDB does not handle code with "time dependency" well.

                  If I am on right track establishing "parent" hierarchy (?) I am back to my "floating window " theory - I cannot prove the QProcess "parent " using GDB.

                  Edit
                  I have added simple debug message

                  void MainWindow::SubWindow(int index) index 10
                  parent QWidget(0x561010725df0, name="tab_148")
                  processTERMINAL->waitForStarted() OK
                  ""
                  ""

                  9572709b-2694-4d81-ae69-a44cff29daec-image.png

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Anonymous_Banned275
                    wrote on last edited by
                    #16

                    Some "news" - not sure if good or bad
                    As far as switching tabs / pages
                    After adding "page as parent " I can open the new page AND the old one moves into background - way below the main MDI window. ( I am not really sure if it is because the parent addition ... did not observed that before...)
                    So it is back to "windows " hierarchy - from being on top - it is now "on bottom of the totem pole " .
                    So - if it can be moved by whatever unknown process - I should be able to delete it ...

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Anonymous_Banned275
                      wrote on last edited by
                      #17

                      ..for time being - I am cheating
                      I just maximize the main window and do not care how many copies of xtrem are hiding behind it .
                      TEMPORARY HACKED

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        Anonymous_Banned275
                        wrote on last edited by
                        #18

                        More success...
                        After adding -info to xterm options the xterm is now actual part of QTabWidget and tabs gets switched properly.
                        If the first page xterm has +hold option it works fine , however every other page has to have -hold . If +hold is also optioned
                        the page just flashes...

                        However -the xterm never gets terminated , its GUI just no longer shows... - something to work on

                        Interestingly and somewhat expected - the QProcess "window / frame " no longer shows either - perhaps another option ??

                        I would like to express my appreciation to all who helped with this messy task.

                        After all this I realized I want to have multiple "xterm" - with different options - visible ...
                        I think "MDI" is next.
                        Thanks

                        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