You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Qt飞镖计分程序双屏显示诉求:隐藏输入窗口,仅投影结果

Great question! For your dart scoring app built with Qt, you have two reliable options to keep the input window hidden from guests while showing only the score output on the projector/secondary screen—one is a quick system-level setup, the other is more controlled Qt programming.

1. System-Level Display Configuration (No Coding Needed)

This is the fastest way to get up and running, perfect if you want to avoid extra code work:

  • Windows: Right-click your desktop → Display settings. Under "Multiple displays", select "Extend these displays". Drag the secondary/projector screen icon to match its physical position, then move your score output window to that screen and maximize it. Keep the input window on your main PC screen—guests will only see what’s displayed on the projector.
  • macOS: Open System Settings → Displays. Hold the Option key and click "Detect Displays" if the secondary screen isn’t showing up, then go to the "Arrangement" tab and select "Extended". Drag the tiny menu bar icon to your main screen (so your input window stays there), then move the score display to the secondary screen.
  • Linux: Depending on your desktop environment (GNOME/KDE), open Display settings and enable extended mode. Separate your input and output windows across screens just like on Windows/macOS.

The only downside is you’ll need to manually arrange the windows each time you launch the app, but it’s a zero-code solution.

2. Qt Programming Implementation (Automated & Controlled)

If you want a seamless, hands-off experience (where the app automatically sends the score display to the secondary screen), Qt has built-in multi-screen support that lets you handle this programmatically. Here’s a step-by-step breakdown:
First, use Qt’s QScreen class to detect available screens and route your windows accordingly:

#include <QGuiApplication>
#include <QScreen>
#include <QMainWindow>

int main(int argc, char *argv[]) {
    QGuiApplication app(argc, argv);

    // Get list of all connected screens
    QList<QScreen*> screens = QGuiApplication::screens();

    if (screens.size() > 1) {
        // Create score display window (use QWidget if you don't need a main window)
        QMainWindow* scoreWindow = new QMainWindow();
        // Assign it to the secondary screen (index 1, since index 0 is primary)
        scoreWindow->setScreen(screens[1]);
        // Set to fullscreen to hide window chrome and fill the projector
        scoreWindow->showFullScreen();

        // Create input window (stays on primary screen by default)
        QMainWindow* inputWindow = new QMainWindow();
        inputWindow->show();
    } else {
        // Fallback if no secondary screen is connected
        QMainWindow* singleScreenWindow = new QMainWindow();
        singleScreenWindow->show();
    }

    return app.exec();
}

You can add extra polish to the score display window to make it guest-friendly:

  • Hide the title bar with scoreWindow->setWindowFlags(Qt::FramelessWindowHint);
  • Ensure it stays on top of other apps with scoreWindow->setWindowFlags(Qt::WindowStaysOnTopHint);

With this code, every time you launch the app, the score display will automatically open fullscreen on the secondary screen, and the input window will stay on your main PC screen—guests won’t see anything but the scoring results.

内容的提问来源于stack exchange,提问作者user6539314

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 09:01:58