本文整理汇总了C++中QTreeWidgetItem::textAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::textAlignment方法的具体用法?C++ QTreeWidgetItem::textAlignment怎么用?C++ QTreeWidgetItem::textAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::textAlignment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printRows
void PrintTreeWidget::printRows(QPainter *p, int sItem, int eItem)
{
QRect rect;
QBrush bbrush;
QString tmpSt;
int yPos;
int xPos = prLeftMargin;
int numCols;
QTreeWidgetItem *curItem;
// Now, draw the report title, centered on the page.
p->setFont(QFont("helvetica", 8, QFont::Normal));
numCols = myTree->columnCount();
if (!numCols) return;
if (numCols > 20) numCols = 20;
yPos = 130;
for (int i = sItem; i < eItem; i++) {
curItem = myTree->topLevelItem(i);
if (curItem) {
if (!myPrintSelectedOnly || curItem->isSelected()) {
xPos = prLeftMargin;
for (int i = 0; i < numCols; i++) {
rect.setCoords(xPos+1, yPos, xPos + prColWidths[i] - 1, yPos+11);
p->drawText(rect, curItem->textAlignment(i)|Qt::AlignVCenter, curItem->text(i));
xPos += prColWidths[i];
}
yPos += 12;
}
}
}
}
示例2: textAlignment
int QTreeWidgetItemProto::textAlignment(int column) const
{
QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
if (item)
return item->textAlignment(column);
return 0;
}
示例3: setHeader
void TreeWidgetHeaderSetupDialog::setHeader(QTreeWidget* view, int)
{
m_view = view;
QTreeWidgetItem* header = view->headerItem();
for( int i=0;i<header->columnCount();i++ )
{
QTreeWidgetItem* item = new QTreeWidgetItem(ui->MasterView);
item->setText(0, header->text(i));
item->setTextAlignment(0, header->textAlignment(i));
item->setCheckState(0, view->isColumnHidden(i) ? Qt::Unchecked : Qt::Checked);
}
}
示例4: GetColumn
bool wxListCtrl::GetColumn(int col, wxListItem& info) const
{
QTreeWidgetItem *qitem = m_qtTreeWidget->headerItem();
if ( qitem != NULL )
{
info.SetText(wxQtConvertString(qitem->text(col)));
info.SetAlign(wxQtConvertAlignFlag(qitem->textAlignment(col)));
info.SetWidth(m_qtTreeWidget->columnWidth(col));
return true;
}
else
return false;
}
示例5: emailReport
/**
* print()
*
* Initiates the actual printing of the list.
*/
void EmailTreeWidget::emailReport()
{
int colWidths[20];
uint numCols;
QString fmtStr;
char tmpStr[4096];
QString tmpQstr;
QString colStr;
QString txtBody;
QString txtStr;
QString csvName;
QDate tmpDate = QDate::currentDate();
QTime tmpTime = QTime::currentTime();
QTreeWidgetItem *hdr;
numCols = myTree->columnCount();
if (!numCols) return;
hdr = myTree->headerItem();
//debug(5,"QListViewToCSV() returned %d lines\n", QListViewToCSV(myTree, "/tmp/test.csv"));
// Get the width of each header item.
for (uint i = 0; i < numCols; i++) {
colWidths[i] = hdr->text(i).length();
}
// Now, get the longest item for each of the keys.
QTreeWidgetItem *curItem;
for (int j = 0; j < myTree->topLevelItemCount(); j++) {
curItem = myTree->topLevelItem(j);
for (uint i = 0; i < numCols; i++) {
if (curItem->text(i).length() > colWidths[i]) {
colWidths[i] = curItem->text(i).length();
}
}
}
// If dates are allowed, then put them in here.
if (showDateLine) {
txtBody += myDateLine;
txtBody += "\n\n";
}
// Okay, now print our headers
for (uint i = 0; i < numCols; i++) {
colStr = hdr->text(i);
if (hdr->textAlignment(i) & Qt::AlignRight) {
colStr = colStr.rightJustify(colWidths[i]+1);
} else {
colStr = colStr.leftJustify(colWidths[i]+1);
}
txtBody += colStr;
}
txtBody += "\n";
// And now a line seperating the headers from the data.
for (uint i = 0; i < numCols; i++) {
strcpy(tmpStr, "");
for (int n = 0; n < colWidths[i]; n++) strcat(tmpStr, "=");
txtBody += tmpStr;
txtBody += " ";
}
txtBody += "\n";
// And now, finally, the data itself
for (int j = 0; j < myTree->topLevelItemCount(); j++) {
curItem = myTree->topLevelItem(j);
for (uint i = 0; i < numCols; i++) {
fmtStr = "%";
if (!(curItem->textAlignment(i) & AlignRight)) fmtStr += "-";
sprintf(tmpStr, "%d", colWidths[i]);
fmtStr += tmpStr;
fmtStr += "s ";
txtBody += txtStr.sprintf(fmtStr.ascii(), curItem->text(i).ascii());
}
txtBody += "\n";
}
txtBody += txtStr.sprintf("\n\nReport generated on %s at %s\n\n", tmpDate.toString().ascii(), tmpTime.toString().ascii());
// Now, create the email.
QString fromAddr;
QString subj;
fromAddr = fromAddr.sprintf("%[email protected]%s", curUser().userName, cfgVal("EmailDomain"));
subj = subj.sprintf("Report - %s", myTitle.ascii());
EmailMessage msg;
msg.setFrom(fromAddr);
msg.setTo(emailAddr->text());
//.........这里部分代码省略.........
示例6: slotProcExited
void PluginKateXMLCheckView::slotProcExited(int exitCode, QProcess::ExitStatus exitStatus)
{
Q_UNUSED(exitCode);
// FIXME: doesn't work correct the first time:
//if( m_dockwidget->isDockBackPossible() ) {
// m_dockwidget->dockBack();
// }
if (exitStatus != QProcess::NormalExit) {
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, QString("1").rightJustified(4,' '));
item->setText(3, "Validate process crashed.");
listview->addTopLevelItem(item);
return;
}
qDebug() << "slotProcExited()";
QApplication::restoreOverrideCursor();
delete m_tmp_file;
QString proc_stderr = QString::fromLocal8Bit(m_proc.readAllStandardError());
m_tmp_file=0;
listview->clear();
uint list_count = 0;
uint err_count = 0;
if( ! m_validating ) {
// no i18n here, so we don't get an ugly English<->Non-english mixup:
QString msg;
if( m_dtdname.isEmpty() ) {
msg = "No DOCTYPE found, will only check well-formedness.";
} else {
msg = '\'' + m_dtdname + "' not found, will only check well-formedness.";
}
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, QString("1").rightJustified(4,' '));
item->setText(3, msg);
listview->addTopLevelItem(item);
list_count++;
}
if( ! proc_stderr.isEmpty() ) {
QStringList lines = proc_stderr.split("\n", QString::SkipEmptyParts);
QString linenumber, msg;
int line_count = 0;
for(QStringList::Iterator it = lines.begin(); it != lines.end(); ++it) {
QString line = *it;
line_count++;
int semicolon_1 = line.indexOf(':');
int semicolon_2 = line.indexOf(':', semicolon_1+1);
int semicolon_3 = line.indexOf(':', semicolon_2+2);
int caret_pos = line.indexOf('^');
if( semicolon_1 != -1 && semicolon_2 != -1 && semicolon_3 != -1 ) {
linenumber = line.mid(semicolon_1+1, semicolon_2-semicolon_1-1).trimmed();
linenumber = linenumber.rightJustified(6, ' '); // for sorting numbers
msg = line.mid(semicolon_3+1, line.length()-semicolon_3-1).trimmed();
} else if( caret_pos != -1 || line_count == lines.size() ) {
// TODO: this fails if "^" occurs in the real text?!
if( line_count == lines.size() && caret_pos == -1 ) {
msg = msg+'\n'+line;
}
QString col = QString::number(caret_pos);
if( col == "-1" ) {
col = "";
}
err_count++;
list_count++;
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, QString::number(list_count).rightJustified(4,' '));
item->setText(1, linenumber);
item->setTextAlignment(1, (item->textAlignment(1) & ~Qt::AlignHorizontal_Mask) | Qt::AlignRight);
item->setText(2, col);
item->setTextAlignment(2, (item->textAlignment(2) & ~Qt::AlignHorizontal_Mask) | Qt::AlignRight);
item->setText(3, msg);
listview->addTopLevelItem(item);
} else {
msg = msg+'\n'+line;
}
}
}
if( err_count == 0 ) {
QString msg;
if( m_validating ) {
msg = "No errors found, document is valid."; // no i18n here
} else {
msg = "No errors found, document is well-formed."; // no i18n here
}
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, QString::number(list_count+1).rightJustified(4,' '));
item->setText(3, msg);
listview->addTopLevelItem(item);
}
}