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. How to run an exe file on a second monitor
Forum Updated to NodeBB v4.3 + New Features

How to run an exe file on a second monitor

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.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.
  • B Offline
    B Offline
    banditblue
    wrote on last edited by
    #1

    Hello

    I'm working on an application which has to run in a PC with two screens.
    The program executes an external exe file with QProcess. The main interface of my program has to go on the first screen and the QProcess/exe file has to go on the second screen. How can I do it? Have I to bind QProcess with a QWidget object?

    Thanks in advance

    banditblue

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

      Depends on how that second program, which you run via QProcess, creates its GUI window. If that program just creates its window on the "primary" screen, then there probably isn't much you can do about that. If the second program is under your control (i.e. you have access to the code), have a look at QDesktopWidget::screenGeometry(n). Just grab the screen you which (by specifying the right index) and then move your window there...

      @const int n = QApplication::desktop()->screenCount();
      for(int i = 0; i < n; i++)
      {
      QRect w = QApplication::desktop()->screenGeometry(i);
      if(!w.isNull())
      {
      qDebug("Screen %d: (%d,%d) -> %d x %d",
      i, w.x(), w.y(), w.width(), w.height());
      }
      }@

      --

      BTW: I think it's also possible to move windows that belong to another process. But this will probably involve some platform-specific code for obtaining a handle to that window and finally moving it around.

      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
      • B Offline
        B Offline
        banditblue
        wrote on last edited by
        #3

        I have done it using win32 api. I want do it now using QT. I would like simply move the the GUI of the exe or encapsulate it in an object which i can manage.

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

          Again: If the window you want to move belongs to the second process, it can only be (easily) moved from with that process. Unless you have the code of the second program and can modify it as needed (or the second program already exposes an option to select the screen), this won't be possible to achieve from the first process, except for using the Win32 API directly.

          Using the Win32 API is more a "hack", but in theory you should be able to grab the handle of the second process' window - from the first process - by using EnumWindows. Then you can move it via SetWindowPos function.

          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
          • B Offline
            B Offline
            banditblue
            wrote on last edited by
            #5

            Thanks for the suggestions.
            I don't have the code of the exe and i don't know how to use QProcess to move the GUI of the exe from the main screen to the second one.

            Sorry for boring questions...

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

              I'm pretty sure QProcess can not do that and was never intended to do that. Only exception would be when the program, that you are about to run, exposes a command-lin switch to select the screen. In that specific case, QProcess could pass the required argument. Otherwise, I don't think you can move the window, which belongs to another process, purely with Qt code.

              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