Qt5 GUI How To Create QPrintDialog

In this Qt5 GUI article iam going to show you How To Create QPrintDialog

The QPrintDialog class provides a dialog for specifying the printer’s configuration.

The dialog allows users to change document-related settings, such as the paper size and orientation, type of print (color or grayscale),

range of pages, and number of copies to print.

Controls are also provided to enable users to choose from the printers available, including any configured network printers.

Typically, QPrintDialog objects are constructed with a QPrinter object, and executed using the exec() function.

 

 

Check Qt5 C++ GUI Development Articles with videos training and source codes.

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

 

 

OK now iam going to use my previous article example on How To Create QMenu, and iam going to add  a new menu item at name of print like this.

Qt5 QPrintDialog
Qt5 QPrintDialog

 

 

So after that you need to open your .pro file and add print support like this

 

After adding your .pro file will look like this

 

 

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

Qt5 QPrint Support
Qt5 QPrint Support

 

 

Also in your mainwindow.ui we need to add a QTextEdit like this

Qt5 QTextEdit
Qt5 QTextEdit

 

 

After that open mainwindow.cpp and in the slot section you need to add this line of code for QPrintDialog.

 

 

So your mainwindow.cpp look like this

 

 

This is the result

Qt5 GUI How To Create QPrintDialog
Qt5 GUI How To Create QPrintDialog

 

 

 

Also you can watch the complete video for this article 

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×