久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

QTableView 打印

QTableView printing(QTableView 打印)
本文介紹了QTableView 打印的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我是 QT 新手,我嘗試從 QTableView 打印出來

I am new on QT an I try to print out from QTableView

我該怎么做?

非常感謝

推薦答案

這是擺脫中間文件的第一個答案的變體.

Here is a variation of the first answer that gets rid of the intermediate file.

QString strStream;
QTextStream out(&strStream);

const int rowCount = pPublic->tableView->model()->rowCount();
const int columnCount = pPublic->tableView->model()->columnCount();

out <<  "<html>
"
    "<head>
"
    "<meta Content="Text/html; charset=Windows-1251">
"
    <<  QString("<title>%1</title>
").arg(strTitle)
    <<  "</head>
"
    "<body bgcolor=#ffffff link=#5000A0>
"
    "<table border=1 cellspacing=0 cellpadding=2>
";

// headers
out << "<thead><tr bgcolor=#f0f0f0>";
for (int column = 0; column < columnCount; column++)
    if (!pPublic->tableView->isColumnHidden(column))
        out << QString("<th>%1</th>").arg(pPublic->tableView->model()->headerData(column, Qt::Horizontal).toString());
out << "</tr></thead>
";

// data table
for (int row = 0; row < rowCount; row++) {
    out << "<tr>";
    for (int column = 0; column < columnCount; column++) {
        if (!pPublic->tableView->isColumnHidden(column)) {
            QString data = pPublic->tableView->model()->data(pPublic->tableView->model()->index(row, column)).toString().simplified();
            out << QString("<td bkcolor=0>%1</td>").arg((!data.isEmpty()) ? data : QString("&nbsp;"));
        }               
    }
    out << "</tr>
";
}
out <<  "</table>
"
    "</body>
"
    "</html>
";

QTextDocument *document = new QTextDocument();
document->setHtml(strStream);

QPrinter printer;

QPrintDialog *dialog = new QPrintDialog(&printer, NULL);
if (dialog->exec() == QDialog::Accepted) {
    document->print(&printer);
}

delete document;

這篇關于QTableView 打印的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 欧美精品网站 | 97国产精品视频人人做人人爱 | 久久精品国产一区二区电影 | 日韩免费福利视频 | 亚洲一区二区久久 | 国产一区二区在线免费观看 | 亚洲国产精品日韩av不卡在线 | 国产一区二区在线视频 | 精品久久精品 | 在线免费国产视频 | 久久极品| 高清一区二区三区 | 色播视频在线观看 | 亚洲日日夜夜 | 亚洲精品一二三区 | 欧美综合久久 | 国产成人精品综合 | 国产91在线 | 亚洲 | 北条麻妃国产九九九精品小说 | 免费观看毛片 | 在线观看中文字幕 | av在线一区二区三区 | 激情一区二区三区 | 一区日韩 | 北条麻妃国产九九九精品小说 | 欧美成ee人免费视频 | 一区二区三区视频在线观看 | 色综合色综合色综合 | 欧美一级片在线观看 | 精品日韩一区二区三区av动图 | 天天天操 | 亚洲精品欧美 | 欧美日高清视频 | www.成人久久 | 五月花丁香婷婷 | 欧美精品在线一区二区三区 | 亚洲精品99 | 欧美专区在线 | 一级黄色播放 | 日韩av网址在线观看 | 第一区在线观看免费国语入口 |