好了长话短说 因为tableview 不提供print 函数 ,所以 要实现打印现在基本是基于 两种 一种是利用render 函数 一种是利用 html 来实现 我个人因为在用render方法的时候 打印预览是空白的 (同事使用相同的代码,在qt4.8+vs2008可以实现) 所以使用了html 来实现 。OK贴代码
// 打印预览
QPrinter printer(QPrinter::ScreenResolution);
QPrintPreviewDialog preview(&printer);
connect(&preview, SIGNAL(paintRequested(QPrinter *)),this,SLOT(print(QPrinter* )));
preview.exec(); //打印 QString strStream,strTitle;QTextStream out(&strStream);strTitle="carman——feng";const int rowCount = ui->tableView->model()->rowCount();</