한국어
Qt
 

Qt 어플리케이션의 기본 폰트를 설정하는 방법

 

#include <QApplication>
#include <QFontDatabase>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    int id = QFontDatabase::addApplicationFont(qApp->applicationDirPath()+"/Daum_Regular.ttf");
    QString family = QFontDatabase::applicationFontFamilies(id).at(0);
    
QFont SerifFont(family);
    a.setFont(SerifFont);

    return a.exec();
}

 

QApplication 객체 생성 후

qApp전역 변수에 접근하여 실행되는 위치에서 폰트파일의 경로를 설정하였다.

그러면 기본적으로 어플리케이션의 폰트는 Daum Regula로 적용된다.

번호 제목 글쓴이 날짜 조회 수
공지 Qt프로그래밍(QtQuick) Beginner를 위한 글 읽는 순서 운영자 2019.01.05 86016
59 Windows에서 Qt D-Bus를 사용하여 프로세스간 통신(IPC) file makersweb 2019.05.02 4487
58 QML과 QtQuick 모듈 개념과 기본 타입들 makersweb 2019.04.26 13421
57 QML 전역 객체 (Global Object) file makersweb 2019.04.10 1053
56 tslib의 ts_calibrate를 응용해서 Qt로 터치보정기능 구현 file makersweb 2019.04.06 1368
55 GPU가 없는 장치에서 Qt Quick을 사용 makersweb 2019.04.02 1857
54 QTextCodec클래스를 사용하여 유니코드와 EUC-KR 변환 makersweb 2019.03.25 2894
53 qInstallMessageHandler를 이용한 디버그 메세지 출력 제어하기 makersweb 2019.02.25 1354
52 Qt5기반 독립 프로세스(out-of-process)로 동작하는 가상키보드(virtual keyboard) file makersweb 2019.02.24 2629
51 Qml 기본 컴포넌트 강좌 (4) - 모델 리스팅(Listing) file 운영자 2019.02.23 5315
50 Qt Bluetooth를 이용한 시리얼(Serial) 통신 file makersweb 2019.02.17 3579
49 Qml 기본 컴포넌트 강좌 (3) - 배치(positioning) 컴포넌트 file 운영자 2019.02.10 4883
48 QString 문자열 다루기 예제 운영자 2019.01.26 40201
47 Qt SQL을 이용한 가벼운 데이터베이스 다루기 [1] file 운영자 2019.01.23 6973
46 구글 클라우드 Speech-To-Text API를 Qt기반(C++, Qml)테스트 [7] file makersweb 2019.01.20 2620
45 QNetworkAccessManager를 통해 HTTP POST 하는 예제 makersweb 2019.01.17 4782
44 Qt응용프로그램 실행 시 콘솔창(터미널)같이 띄우기 file makersweb 2019.01.16 4494
43 안드로이드 가상장치 사용 file makersweb 2019.01.13 1074
42 Qml 기본 컴포넌트 강좌 (2) [2] file makersweb 2019.01.05 8637
41 Qml 기본 컴포넌트 강좌 (1) file makersweb 2019.01.03 12097
40 QtWayland와 ivi-compositor file makersweb 2018.12.27 2407