I have been trying to solve Qt printing issue for 2 days without much luck. I have a very simple program, which should print text from QTextEdit. I have Qt Creator 4.3.0 Based on Qt 5.8.0 (MSVC 2015, 32 bit) running on Windows 7 64 bit.

I added printsupport in project file,

```
QT       += core gui sql printsupport

```

I added references in header file,

```
#include <QWidget>
#include <QPrinter>
#include <QPrintDialog>
#include <QPrinterInfo>
#include <QDialog>
#include <QFile>
#include <QMessageBox>
#include <QTextStream>

```

and finally, I added pushbutton click() slot in c++ file.

```
void MyClass::on_btnPrint_clicked()
{
  QPrinter printer;
  QPrintDialog printDialog(&printer, this);
  if (printDialog.exec() == QDialog::Accepted) {
       ui->textEdit->print(&printer);
  }
}

```

When I click print button in debug mode, it gives me following error,

```
QWin32PrintEngine::initialize: CreateDC failed ()

```

and following dialog appears in Windows 7:

[![enter image description here](https://i.stack.imgur.com/FlZtx.png)](https://i.stack.imgur.com/FlZtx.png)

I already have an installed default printer on my computer.
I searched QT support, but I could not find a solution. This has also not been reported as a bug. I would appreciate your help.