내가 책을 보면서도 컴퓨터 해상도를 구하기를 찾지 못하여 결국은
Qt Assistant에서 찾아 보았다.
일단 아는 정보가 없기 때문에 Screen이라는 검색어로 찾아 보니 결국은 있었다.
간단한 예제 소스를 보게 되면,
#include#include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); QMessageBox *box = new QMessageBox; QString str; int widthNumber; int heightNumber; widthNumber = QApplication::desktop()->screenGeometry().width(); heightNumber = QApplication::desktop()->screenGeometry().height(); str.sprintf("%d %d",widthNumber, heightNumber); box->setText(str); box->show(); return app.exec(); }
이런식으로 구현을 하였다.
그래서 결과 화면을 보면
이렇게 실제 해상도와 같다는 것을 확인 하였다.
간단히 소스 분석을 하면,
일단 QApplication::desktop()->screenGeometry() 이 함수로 해상도를 구하고
str.sprintf("%d %d",widthNumber, heightNumber);
이 작업으로 변수 값들을 문자열로 바꾸었다.
'QT > QT 4.6.2' 카테고리의 다른 글
MAC, IP 주소 알아내기 (0) | 2010.06.01 |
---|---|
파일의 특정 부분 입 / 출력하기 (QTextStream::readLine, QString::split) (1) | 2010.05.27 |
QTextStream와 QDataStream의 차이 비교 (1) | 2010.05.21 |
Phonon::MediaObject (0) | 2010.05.06 |
간단한 파일 입 / 출력 하기!! (0) | 2010.04.30 |