화면 캡처 예시
화면 또는 창 캡처하기.
화면 캡처는 QScreenCapture 및 QWindowCapture 을 사용하여 화면 또는 창을 캡처하는 방법을 보여줍니다. 이 예에서는 화면 및 창 목록을 보여주고 QMediaCaptureSession 및 QVideoWidget 을 사용하여 선택한 항목의 실시간 미리 보기를 표시합니다. button 을 사용하여 캡처를 시작하고 중지할 수 있습니다.
예제 실행하기
에서 예제를 실행하려면 Qt Creator에서 Welcome 모드를 열고 Examples 에서 예제를 선택합니다. 자세한 내용은 예제 빌드 및 실행하기를 참조하세요.
애플리케이션 구조
이 예제는 세 개의 사용자 지정 클래스로 구성됩니다. UI와 모든 화면 캡처 기능은 ScreenCapturePreview 클래스에서 구현됩니다. ScreenListModel 및 WindowListModel 클래스는 두 개의 QListView 위젯 뒤에 있는 모델 역할만 합니다. 메인 함수는 모든 UI 위젯 외에 QScreenCapture 및 QWindowCapture, QMediaCaptureSession 및 QVideoWidget 의 인스턴스를 차례로 생성하는 ScreenCapturePreview 객체를 생성합니다.
화면 및 창 모델은 각각 QGuiApplication::screens() 및 QWindowCapture::capturableWindows()의 반환 값으로 채워집니다.
목록 항목이 선택되면 setScreen()를 통해 QScreenCapture 객체에 연결되거나 QWindowCapture ()를 통해 setWindow 객체에 연결됩니다. 캡처 객체는 각각 setScreenCapture() 및 setWindowCapture()를 사용하여 QMediaCaptureSession 객체에 연결됩니다. 캡처 세션은 차례로 setVideoOutput()를 사용하여 QVideoWidget 객체에 연결됩니다. 따라서 캡처 출력은 UI의 오른쪽에 있는 비디오 위젯에서 미리 볼 수 있습니다.
시작/중지 버튼은 QScreenCapture::start() 및 QScreenCapture::stop() 또는 QWindowCapture::start() 및 QWindowCapture::stop()를 호출합니다.
errorOccurred 신호가 발생하면 QMessageBox 가 팝업됩니다.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.