当前位置: 首页>>代码示例>>C++>>正文


C++ QTextDocument::pageCount方法代码示例

本文整理汇总了C++中QTextDocument::pageCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextDocument::pageCount方法的具体用法?C++ QTextDocument::pageCount怎么用?C++ QTextDocument::pageCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextDocument的用法示例。


在下文中一共展示了QTextDocument::pageCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pageCount

int QTextDocumentProto::pageCount() const
{
  QTextDocument *item = qscriptvalue_cast<QTextDocument*>(thisObject());
  if (item)
    return item->pageCount();
  return 0;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: printTable

void PrintLayout::printTable() const
{
	QTextDocument doc;
	QSizeF pageSize;
	pageSize.setWidth(pageRect.width());
	pageSize.setHeight(pageRect.height());
	doc.setPageSize(pageSize);

	QString styleSheet(
		"<style type='text/css'>" \
		"table {" \
		"	border-width: 1px;" \
		"	border-style: solid;" \
		"	border-color: #999999;" \
		"}" \
		"th {" \
		"	background-color: #eeeeee;" \
		"	font-size: small;" \
		"	padding: 3px 5px 3px 5px;" \
		"}" \
		"td {" \
		"	font-size: small;" \
		"	padding: 3px 5px 3px 5px;" \
		"}" \
		"</style>"
	);
	// setDefaultStyleSheet() doesn't work here?
	QString htmlText = styleSheet + "<table cellspacing='0' width='100%'>";
	QString htmlTextPrev;
	int pageCountNew = 1, pageCount;
	bool insertHeading = true;

	int i;
	struct dive *dive;
	for_each_dive(i, dive) {
		if (!dive->selected && printOptions->print_selected)
			continue;
		if (insertHeading) {
			htmlText += insertTableHeadingRow();
			insertHeading = false;
		}
		htmlTextPrev = htmlText;
		htmlText += insertTableDataRow(dive);
		doc.setHtml(htmlText);
		pageCount = pageCountNew;
		pageCountNew = doc.pageCount();
		/* if the page count increases after adding this row we 'revert'
		 * and add a heading instead. */
		if (pageCountNew > pageCount) {
			htmlText = htmlTextPrev;
			insertHeading = true;
			i--;
		}
	}
	htmlText += "</table>";
	doc.setHtml(htmlText);
	doc.print(printer);
}
开发者ID:kuldipem,项目名称:subsurface,代码行数:58,代码来源:printlayout.cpp

示例3: printTable

void PrintLayout::printTable() const
{
	QTextDocument doc;
	QSizeF pageSize;
	pageSize.setWidth(pageRect.width());
	pageSize.setHeight(pageRect.height());
	doc.documentLayout()->setPaintDevice(printer);
	doc.setPageSize(pageSize);

	QString styleSheet(
		"<style type='text/css'>"
		"table {"
		"	border-width: 1px;"
		"	border-style: solid;"
		"	border-color: #999999;"
		"}"
		"th {"
		"	background-color: #eeeeee;"
		"	font-size: small;"
		"	padding: 3px 5px 3px 5px;"
		"}"
		"td {"
		"	font-size: small;"
		"	padding: 3px 5px 3px 5px;"
		"}" 
		"</style>"
	);
	// setDefaultStyleSheet() doesn't work here?
	const QString heading(insertTableHeadingRow());
	const QString lineBreak("<br>");
	QString htmlText = styleSheet + "<table cellspacing='0' width='100%'>";
	QString htmlTextPrev;
	int pageCountNew = 1, pageCount = 0, lastPageWithHeading = 0;
	bool insertHeading = true;

	int i;
	struct dive *dive;
	for_each_dive(i, dive) {
		if (!dive->selected && printOptions->print_selected)
			continue;
		if (insertHeading) {
			htmlTextPrev = htmlText;
			htmlText += heading;
			doc.setHtml(htmlText);
			pageCount = doc.pageCount();
			// prevent adding two headings on the same page
			if (pageCount == lastPageWithHeading) {
				htmlText = htmlTextPrev;
				// add line breaks until a new page is reached
				while (pageCount == lastPageWithHeading) {
					htmlTextPrev = htmlText;
					htmlText += lineBreak;
					doc.setHtml(htmlText);
					pageCount = doc.pageCount();
				}
				// revert last line break from the new page and add heading
				htmlText = htmlTextPrev;
				htmlText += heading;
			}
			insertHeading = false;
			lastPageWithHeading = pageCount;
		}
		htmlTextPrev = htmlText;
		htmlText += insertTableDataRow(dive);
		doc.setHtml(htmlText);
		pageCount = pageCountNew;
		pageCountNew = doc.pageCount();
		// if the page count increases revert and add heading instead
		if (pageCountNew > pageCount) {
			htmlText = htmlTextPrev;
			insertHeading = true;
			i--;
		}
	}
	htmlText += "</table>";
	doc.setHtml(htmlText);
	doc.print(printer);
}
开发者ID:allenh1,项目名称:subsurface,代码行数:78,代码来源:printlayout.cpp


注:本文中的QTextDocument::pageCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。