Qt5 GUI How To Create QFontDialog

In this Qt5 GUI i want to show you How To Create QFontDialog.

The QFontDialog class provides a dialog widget for selecting a font. A font dialog is created through one of the static getFont() functions.

 

Example:

 

Also the dialog can also be used to set a widget’s font directly:

 

 

 

Check Qt5 C++ GUI Development Articles in the below links

 

1: Qt5 C++ Introduction And Installation

2: Qt5 C++ First Console Application 

3: Qt5 C++ First GUI Application 

4: Qt5 C++ Signal And Slots Introduction

5: Qt5 C++ Layout Management 

6: Qt5 C++ Creating Qt Style Sheets

7: Qt5 C++ Creating QPushButton

8: How To Create QCheckBox in Qt5

9: Qt5 GUI How To Create QRadioButton

10: Qt5 GUI Development How To Create ComboBox

11: Qt5 C++ GUI Development Creating QListWidget

12: Qt5 C++ GUI Development Creating QMessageBox

13 : Qt5 C++ GUI Creating QMenu And QToolbar

14: Qt5 C++ GUI Development Creating QPrintDialog

OK now iam going to use my previous article example on How To Create QMenu, also iam going to add a new Menu with a new Menu Item like this.

make sure that you have an icon for the menu item in your resource file

Qt5 QFont Dialog
Qt5 QFont Dialog

OK now right click on your menu item after that choose Go To Slot  and from the dialog choose triggered() like this.

Qt5 FontDialog Creation
Qt5 FontDialog Creation

So now open your mainwindow.h file and in the header add QFontDialog class like this

 

 

After adding your mainwindow.h file will look like this

 

Now open your mainwindow.cpp and these codes in the slot

 

After adding your mainwindow.cpp will look like this

 

And at the end this will be the result

Qt5 GUI How To Create QFontDialog
Qt5 GUI How To Create QFontDialog

 

 

 

 

Also you can watch the complete video for this article

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×