QPrinter When click button my program crashes Why?
问题 When i click the button, the program crashes. I will post my code: void Test1::on_pushButton_1_clicked() // print the information { QPrinter printer(QPrinter::HighResolution); printer.setCreator("Me"); printer.setDocName("Print"); printer.setPaperSize(QPrinter::A4); QPrintPreviewDialog *pd = new QPrintPreviewDialog(&printer); connect(pd,SIGNAL(paintRequested(QPrinter*)),this,SLOT(print(QPrinter*))); pd->exec(); } void Test1::print(QPrinter *p) { QPainter painter(p); painter.setPen(Qt::blue);