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. Is there a similar "unset DISPLAY" setting method in QT, that is, the program is not allowed to display any new windows
Forum Updated to NodeBB v4.3 + New Features

Is there a similar "unset DISPLAY" setting method in QT, that is, the program is not allowed to display any new windows

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 336 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 Offline
    J Offline
    jiaming
    wrote on 4 Mar 2021, 07:03 last edited by
    #1

    When I start a program with qprocess, it will pop up a new window. If I start the program in terminal, I can enter the unset DISPLAY command first to stop displaying the new window, but the unset DISPLAYcommand doesn't seem to work in QT. The QT version is 5.12

    J 1 Reply Last reply 4 Mar 2021, 08:58
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 4 Mar 2021, 08:05 last edited by
      #2

      Hi
      What did you try to use "unset"
      Something like this ?
      https://doc.qt.io/qt-5/qprocess.html#setProcessEnvironment

      J 1 Reply Last reply 4 Mar 2021, 09:34
      2
      • J jiaming
        4 Mar 2021, 07:03

        When I start a program with qprocess, it will pop up a new window. If I start the program in terminal, I can enter the unset DISPLAY command first to stop displaying the new window, but the unset DISPLAYcommand doesn't seem to work in QT. The QT version is 5.12

        J Offline
        J Offline
        JonB
        wrote on 4 Mar 2021, 08:58 last edited by JonB 3 Apr 2021, 08:59
        #3

        @jiaming
        As @mrjj has said, the cleanest way to do this is to copy the parent's environment variables excluding DISPLAY to the environment for the child process. If you don't want to do that, if you are under Linux you may find running QProcess command env DISPLAY= <your-command> (note the spacing, DISPLAY= is an argument of its own) does the job (test from command line first).

        1 Reply Last reply
        2
        • M mrjj
          4 Mar 2021, 08:05

          Hi
          What did you try to use "unset"
          Something like this ?
          https://doc.qt.io/qt-5/qprocess.html#setProcessEnvironment

          J Offline
          J Offline
          jiaming
          wrote on 4 Mar 2021, 09:34 last edited by
          #4

          @mrjj @JonB
          I realized this function through the following code, thank you

          QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
          env.remove("DISPLAY");
          proc->setProcessEnvironment(env);
          
          1 Reply Last reply
          2

          1/4

          4 Mar 2021, 07:03

          • Login

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