本文整理汇总了C++中QTreeWidgetItem::setTextAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::setTextAlignment方法的具体用法?C++ QTreeWidgetItem::setTextAlignment怎么用?C++ QTreeWidgetItem::setTextAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::setTextAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PopulateTreeWidgetItems
void FlyLinks::PopulateTreeWidgetItems(
const QMap<QString,QString>& objDataMap) {
QMapIterator<QString,QString> objIterMap(objDataMap);
QFont font;
font.setPointSizeF(8.25);
font.setUnderline(true);
m_pObjPopup->setSortingEnabled(false);
QBrush brush(QColor(85, 0, 255, 255));
brush.setStyle(Qt::NoBrush);
QTreeWidgetItem *pItem = new QTreeWidgetItem(m_pObjPopup);
pItem = m_pObjPopup->headerItem();
pItem->setText(0,tr("1"));
pItem->setFont(0, font);
pItem->setForeground(0, brush);
pItem->setTextAlignment(0, Qt::AlignLeft);
m_pObjTreeItemsVec.push_back(pItem);
int iCount = 0;
while(objIterMap.hasNext()) {
objIterMap.next();
QBrush brush(QColor(85, 0, 255, 255));
brush.setStyle(Qt::NoBrush);
QTreeWidgetItem *pItem = new QTreeWidgetItem(m_pObjPopup);
pItem = m_pObjPopup->topLevelItem(iCount++);
pItem->setText(0,objIterMap.key());
pItem->setData(0,Qt::UserRole,objIterMap.value());
pItem->setFont(0, font);
pItem->setForeground(0, brush);
pItem->setTextAlignment(0, Qt::AlignLeft);
}
}
示例2: searchComponents
void AddComponentDialog::searchComponents(const QString& input) {
setSelectedComponent(nullptr);
mUi->treeComponents->clear();
// min. 2 chars to avoid freeze on entering first character due to huge result
if (input.length() > 1) {
SearchResult result = searchComponentsAndDevices(input);
QHashIterator<FilePath, SearchResultComponent> cmpIt(result);
while (cmpIt.hasNext()) {
cmpIt.next();
QTreeWidgetItem* cmpItem = new QTreeWidgetItem(mUi->treeComponents);
cmpItem->setText(0, cmpIt.value().name);
cmpItem->setData(0, Qt::UserRole, cmpIt.key().toStr());
QHashIterator<FilePath, SearchResultDevice> devIt(cmpIt.value().devices);
while (devIt.hasNext()) {
devIt.next();
QTreeWidgetItem* devItem = new QTreeWidgetItem(cmpItem);
devItem->setText(0, devIt.value().name);
devItem->setData(0, Qt::UserRole, devIt.key().toStr());
devItem->setText(1, devIt.value().pkgName);
devItem->setTextAlignment(1, Qt::AlignRight);
}
cmpItem->setText(1, QString("[%1]").arg(cmpIt.value().devices.count()));
cmpItem->setTextAlignment(1, Qt::AlignRight);
cmpItem->setExpanded(!cmpIt.value().match);
}
}
mUi->treeComponents->sortByColumn(0, Qt::AscendingOrder);
}
示例3: QTreeWidgetItem
void K3b::ImageWritingDialog::Private::createCueBinItems( const QString& cueFile, const QString& imageFile )
{
QTreeWidgetItem* isoRootItem = new QTreeWidgetItem( infoView );
isoRootItem->setText( 0, i18n("Detected:") );
isoRootItem->setText( 1, i18n("Cue/bin image") );
isoRootItem->setForeground( 0, infoTextColor );
isoRootItem->setIcon( 1, KIcon( "application-x-cd-image") );
isoRootItem->setTextAlignment( 0, Qt::AlignRight );
QTreeWidgetItem* item = new QTreeWidgetItem( infoView );
item->setText( 0, i18n("Filesize:") );
item->setText( 1, KIO::convertSize( K3b::filesize(KUrl(imageFile)) ) );
item->setForeground( 0, infoTextColor );
item->setTextAlignment( 0, Qt::AlignRight );
item = new QTreeWidgetItem( infoView );
item->setText( 0, i18n("Image file:") );
item->setText( 1, imageFile );
item->setForeground( 0, infoTextColor );
item->setTextAlignment( 0, Qt::AlignRight );
item = new QTreeWidgetItem( infoView );
item->setText( 0, i18n("Cue file:") );
item->setText( 1, cueFile );
item->setForeground( 0, infoTextColor );
item->setTextAlignment( 0, Qt::AlignRight );
}
示例4: qtractorFileListView
// Constructor.
qtractorMidiListView::qtractorMidiListView ( QWidget *pParent )
: qtractorFileListView(qtractorFileList::Midi, pParent)
{
QTreeWidget::setColumnCount(qtractorMidiListView::LastColumn + 1);
QTreeWidgetItem *pHeaderItem = QTreeWidget::headerItem();
pHeaderItem->setText(qtractorMidiListView::Name, tr("Name"));
pHeaderItem->setText(qtractorMidiListView::Format, tr("Fmt"));
pHeaderItem->setText(qtractorMidiListView::Tracks, tr("Tracks"));
pHeaderItem->setText(qtractorMidiListView::Resolution, tr("tpqn"));
pHeaderItem->setText(qtractorMidiListView::Path, tr("Path"));
pHeaderItem->setText(qtractorMidiListView::LastColumn, QString::null);
pHeaderItem->setTextAlignment(
qtractorMidiListView::Format, Qt::AlignRight);
pHeaderItem->setTextAlignment(
qtractorMidiListView::Tracks, Qt::AlignRight);
pHeaderItem->setTextAlignment(
qtractorMidiListView::Resolution, Qt::AlignRight);
QHeaderView *pHeader = QTreeWidget::header();
pHeader->resizeSection(qtractorMidiListView::Name, 160);
QTreeWidget::resizeColumnToContents(qtractorMidiListView::Format);
QTreeWidget::resizeColumnToContents(qtractorMidiListView::Tracks);
QTreeWidget::resizeColumnToContents(qtractorMidiListView::Resolution);
pHeader->resizeSection(qtractorMidiListView::Path, 160);
}
示例5: QDialog
UpdateCenterImpl::UpdateCenterImpl(Updates *updates, bool autoDownloadAndInstall, QWidget * parent, Qt::WindowFlags f)
: QDialog(parent, f)
{
setupUi(this);
// resize for macosx
#ifndef Q_OS_WIN32
resize(630, 366);
#endif
closedByButton = false;
// version
lblxVSTVersion->setText(QString(lblxVSTVersion->text()).arg(PROGRAM_VERSION));
// set update class
this->updates = updates;
// configure updates list
QStringList headers;
headers << tr(" File ") << tr(" Version ") << tr(" Size ") << tr(" Progress ");
// add the headers
lsvUpdates->setHeaderLabels(headers);
// change headers sizes
QFontMetrics fm = fontMetrics();
QHeaderView *header = lsvUpdates->header();
// resize
header->resizeSection(1, fm.width(headers.at(0) + "9.99.999 alpha"));
header->resizeSection(2, fm.width(headers.at(1) + " 1024,99Mb "));
// configure resize mode
header->setHighlightSections(false);
header->setStretchLastSection(false);
header->setSectionResizeMode(0, QHeaderView::Stretch);
// set header text aligment
QTreeWidgetItem * headerItem = lsvUpdates->headerItem();
headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(2, Qt::AlignRight | Qt::AlignVCenter);
headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
// fill data
fillUpdates();
// signals
connect(lsvUpdates, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(itemChanged(QTreeWidgetItem*, int)));
connect(btnCancel, SIGNAL(clicked()), this, SLOT(btnCancelClicked()));
connect(btnUpdate, SIGNAL(clicked()), this, SLOT(btnUpdateClicked()));
// updater
connect(updates, SIGNAL(downloadingUpdate(int, int, int)), this, SLOT(downloadingUpdate(int, int, int)));
connect(updates, SIGNAL(downloadUpdateFinished(int)), this, SLOT(downloadUpdateFinished(int)));
connect(updates, SIGNAL(downloadUpdateError(int)), this, SLOT(downloadUpdateError(int)));
connect(updates, SIGNAL(downloadsFinished()), this, SLOT(downloadsFinished()));
connect(updates, SIGNAL(readyToInstallUpdates()), this, SLOT(readyToInstallUpdates()));
connect(updates, SIGNAL(failedToInstallUpdates()), this, SLOT(failedToInstallUpdates()));
// if auto download & install updates, then...
if (autoDownloadAndInstall)
{
// disable update button
lsvUpdates->setEnabled(false);
btnUpdate->setEnabled(false);
// start automatically to download updates (in 500ms)
QTimer::singleShot(500, this, SLOT(btnUpdateClicked()));
}
}
示例6: updateTreeWidget
void PublicationDashboardWindow::updateTreeWidget() {
ui.treeWidget->clear();
//find records in range
QList<PublicationRecord> recordsInRange = filterByDateRange(records,
ui.startDateSelector->date(),
ui.endDateSelector->date());
//count the records
QMap<QString, int> pubTypeSummary;
QMap<QString, QMap<QString, int>> nameSummary;
QMap<QString, QMap<QString, QSet<QString>>> titleSummary;
for (const PublicationRecord &record : recordsInRange) {
++pubTypeSummary[record.type];
++nameSummary[record.type][record.memberName];
titleSummary[record.type][record.memberName].insert(record.title);
}
//build the view
QTreeWidgetItem *root = new QTreeWidgetItem(ui.treeWidget, (QStringList() <<
"Publications" << "" << "" << "" << QString::number(recordsInRange.size())));
root->setTextAlignment(totalNumColumn, Qt::AlignRight);
ui.treeWidget->expandItem(root);
for (auto pubType = pubTypeSummary.begin(); pubType != pubTypeSummary.end(); ++pubType) {
QTreeWidgetItem *pubNode = new QTreeWidgetItem(root, (QStringList() <<
"" << pubType.key() << "" << "" << QString::number(pubType.value())));
pubNode->setTextAlignment(totalNumColumn, Qt::AlignRight);
QMap<QString, int> &currNameSummary = nameSummary[pubType.key()];
for (auto name = currNameSummary.begin(); name != currNameSummary.end(); ++name) {
QTreeWidgetItem *nameNode = new QTreeWidgetItem(pubNode, (QStringList() <<
"" << "" << name.key() << "" << QString::number(name.value())));
nameNode->setTextAlignment(totalNumColumn, Qt::AlignRight);
QSet<QString> &currTitleSummary = titleSummary[pubType.key()][name.key()];
for (QString &title : sortSet(currTitleSummary)) {
QTreeWidgetItem *titleNode = new QTreeWidgetItem(nameNode, (QStringList() <<
"" << "" << "" << title << ""));
titleNode->setTextAlignment(totalNumColumn, Qt::AlignRight);
}
}
}
//set the dropdown values
ui.visualizationFacultyNameSelector->clear();
ui.visualizationFacultyNameSelector->addItems(listFacultyNames(recordsInRange));
setColumnWidths();
}
示例7: RsAutoUpdatePage
ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
: RsAutoUpdatePage(5000, parent, flags)
{
setupUi(this);
QObject::connect(NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged()));
QObject::connect(NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,const QString&,const QString&)), this, SLOT(displayChatLobbyEvent(qulonglong,int,const QString&,const QString&)));
QObject::connect(NotifyQt::getInstance(), SIGNAL(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites()));
QObject::connect(lobbyTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(lobbyTreeWidgetCostumPopupMenu()));
QObject::connect(lobbyTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
QObject::connect(newlobbypushButton, SIGNAL(clicked()), this, SLOT(createChatLobby()));
compareRole = new RSTreeWidgetItemCompareRole;
compareRole->setRole(COLUMN_NAME, ROLE_SORT);
lobbyTreeWidget->setColumnCount(COLUMN_COUNT);
lobbyTreeWidget->sortItems(COLUMN_NAME, Qt::AscendingOrder);
QTreeWidgetItem *headerItem = lobbyTreeWidget->headerItem();
headerItem->setText(COLUMN_NAME, tr("Name"));
headerItem->setText(COLUMN_USER_COUNT, tr("Count"));
headerItem->setText(COLUMN_TOPIC, tr("Topic"));
headerItem->setTextAlignment(COLUMN_NAME, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_TOPIC, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_USER_COUNT, Qt::AlignHCenter | Qt::AlignVCenter);
QHeaderView *header = lobbyTreeWidget->header();
header->setResizeMode(COLUMN_NAME, QHeaderView::Interactive);
header->setResizeMode(COLUMN_USER_COUNT, QHeaderView::Interactive);
header->setResizeMode(COLUMN_TOPIC, QHeaderView::Stretch);
lobbyTreeWidget->setColumnWidth(COLUMN_NAME, 200);
lobbyTreeWidget->setColumnWidth(COLUMN_USER_COUNT, 50);
privateLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
privateLobbyItem->setText(COLUMN_NAME, tr("Private Lobbies"));
privateLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "1");
privateLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE);
lobbyTreeWidget->insertTopLevelItem(0, privateLobbyItem);
publicLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
publicLobbyItem->setText(COLUMN_NAME, tr("Public Lobbies"));
publicLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "2");
publicLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC);
lobbyTreeWidget->insertTopLevelItem(1, publicLobbyItem);
lobbyTreeWidget->expandAll();
lobbyChanged();
}
示例8: retranslateUi
void RoomSelector::retranslateUi()
{
setTitle(tr("Rooms"));
joinButton->setText(tr("Joi&n"));
QTreeWidgetItem *header = roomList->headerItem();
header->setText(0, tr("Room"));
header->setText(1, tr("Description"));
header->setText(2, tr("Permissions"));
header->setText(3, tr("Players"));
header->setText(4, tr("Games"));
header->setTextAlignment(2, Qt::AlignRight);
header->setTextAlignment(3, Qt::AlignRight);
header->setTextAlignment(4, Qt::AlignRight);
}
示例9: QDialog
QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
: QDialog( tool->canvas()->topLevelWidget(), f ), mTool( tool )
{
setupUi( this );
QPushButton *nb = new QPushButton( tr( "&New" ) );
buttonBox->addButton( nb, QDialogButtonBox::ActionRole );
connect( nb, SIGNAL( clicked() ), this, SLOT( restart() ) );
mMeasureArea = tool->measureArea();
mTotal = 0.;
// Set one cell row where to update current distance
// If measuring area, the table doesn't get shown
QTreeWidgetItem* item = new QTreeWidgetItem( QStringList( QString::number( 0, 'f', 1 ) ) );
item->setTextAlignment( 0, Qt::AlignRight );
mTable->addTopLevelItem( item );
//mTable->setHeaderLabels(QStringList() << tr("Segments (in meters)") << tr("Total") << tr("Azimuth") );
QSettings settings;
int s = settings.value( "/qgis/measure/projectionEnabled", "2" ).toInt();
if ( s == 2 )
mcbProjectionEnabled->setCheckState( Qt::Checked );
else
mcbProjectionEnabled->setCheckState( Qt::Unchecked );
connect( mcbProjectionEnabled, SIGNAL( stateChanged( int ) ),
this, SLOT( changeProjectionEnabledState() ) );
updateUi();
}
示例10: addHistoryItems
void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, EditorView *view,
OpenEditorsModel *model, QSet<IDocument *> &documentsDone)
{
foreach (const EditLocation &hi, history) {
if (hi.document.isNull() || documentsDone.contains(hi.document))
continue;
documentsDone.insert(hi.document.data());
QString title = model->displayNameForDocument(hi.document);
QTC_ASSERT(!title.isEmpty(), continue);
QTreeWidgetItem *item = new QTreeWidgetItem();
if (hi.document->isModified())
title += tr("*");
item->setIcon(0, !hi.document->fileName().isEmpty() && hi.document->isFileReadOnly()
? model->lockedIcon() : m_emptyIcon);
item->setText(0, title);
item->setToolTip(0, hi.document->fileName());
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.document.data()));
item->setData(0, Qt::UserRole+1, QVariant::fromValue(view));
item->setTextAlignment(0, Qt::AlignLeft);
m_editorList->addTopLevelItem(item);
if (m_editorList->topLevelItemCount() == 1){
m_editorList->setCurrentItem(item);
}
}
}
示例11: addPoint
void QgsMeasureDialog::addPoint( QgsPoint &p )
{
Q_UNUSED( p );
int numPoints = mTool->points().size();
if ( mMeasureArea && numPoints > 2 )
{
double area = mDa.measurePolygon( mTool->points() );
editTotal->setText( formatArea( area ) );
}
else if ( !mMeasureArea && numPoints >= 1 )
{
if ( !mTool->done() )
{
QTreeWidgetItem * item = new QTreeWidgetItem( QStringList( QLocale::system().toString( 0.0, 'f', mDecimalPlaces ) ) );
item->setTextAlignment( 0, Qt::AlignRight );
mTable->addTopLevelItem( item );
mTable->scrollToItem( item );
}
if ( numPoints > 1 )
{
mTotal = mDa.measureLine( mTool->points() );
editTotal->setText( formatDistance( mTotal ) );
}
}
QgsDebugMsg( "Exiting" );
}
示例12: showQslCards
void qsldb::showQslCards(QString q)
{
cardList->clear();
res = db->Query(q);
if(db->GetState()) {
qDebug() << db->GetError();
}
n = 0;
while( res->Next() != 0) {
r = 1;
i = 0;
rows = res->GetCurrentRow();
QTreeWidgetItem *item = new QTreeWidgetItem(cardList);
item->setText(i++,rows->GetField(r++));
item->setText(i++,rows->GetField(r++));
item->setText(i++,rows->GetField(r++));
item->setText(i++,rows->GetField(r++));
item->setText(i,rows->GetField(r++));
item->setTextAlignment(i++,Qt::AlignCenter);
item->setText(i++,rows->GetField(r++));
n++;
}
res->Close();
p.setNum(n);
labeldbSize->setText("Qsl Bestand: "+p);
}
示例13: showCompletion
//! [5]
void GSuggestCompletion::showCompletion(const QStringList &choices, const QStringList &hits)
{
if (choices.isEmpty() || choices.count() != hits.count())
return;
const QPalette &pal = editor->palette();
QColor color = pal.color(QPalette::Disabled, QPalette::WindowText);
popup->setUpdatesEnabled(false);
popup->clear();
for (int i = 0; i < choices.count(); ++i) {
QTreeWidgetItem * item;
item = new QTreeWidgetItem(popup);
item->setText(0, choices[i]);
item->setText(1, hits[i]);
item->setTextAlignment(1, Qt::AlignRight);
item->setTextColor(1, color);
}
popup->setCurrentItem(popup->topLevelItem(0));
popup->resizeColumnToContents(0);
popup->resizeColumnToContents(1);
popup->adjustSize();
popup->setUpdatesEnabled(true);
int h = popup->sizeHintForRow(0) * qMin(7, choices.count()) + 3;
popup->resize(popup->width(), h);
popup->move(editor->mapToGlobal(QPoint(0, editor->height())));
popup->setFocus();
popup->show();
}
示例14: QDialog
QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
: QDialog( tool->canvas()->topLevelWidget(), f ), mTool( tool )
{
setupUi( this );
QPushButton *nb = new QPushButton( tr( "&New" ) );
buttonBox->addButton( nb, QDialogButtonBox::ActionRole );
connect( nb, SIGNAL( clicked() ), this, SLOT( restart() ) );
mMeasureArea = tool->measureArea();
mTotal = 0.;
// Set one cell row where to update current distance
// If measuring area, the table doesn't get shown
QTreeWidgetItem* item = new QTreeWidgetItem( QStringList( QString::number( 0, 'f', 1 ) ) );
item->setTextAlignment( 0, Qt::AlignRight );
mTable->addTopLevelItem( item );
// Update whenever the canvas has refreshed. Maybe more often than needed,
// but at least every time any canvas related settings changes
connect( mTool->canvas(), SIGNAL( mapCanvasRefreshed() ),
this, SLOT( updateSettings() ) );
updateSettings();
}
示例15: setEditors
void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenEditorsModel *model)
{
m_editorList->clear();
bool first = true;
QSet<IFile*> filesDone;
foreach (const EditLocation &hi, view->editorHistory()) {
if (hi.file.isNull() || filesDone.contains(hi.file))
continue;
QString title = model->displayNameForFile(hi.file);
QTC_ASSERT(!title.isEmpty(), continue;)
filesDone.insert(hi.file.data());
QTreeWidgetItem *item = new QTreeWidgetItem();
if (hi.file->isModified())
title += tr("*");
item->setIcon(0, hi.file->isReadOnly() ? model->lockedIcon() : m_emptyIcon);
item->setText(0, title);
item->setToolTip(0, hi.file->fileName());
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.file.data()));
item->setData(0, Qt::UserRole+1, QVariant::fromValue(view));
item->setTextAlignment(0, Qt::AlignLeft);
m_editorList->addTopLevelItem(item);
if (first){
m_editorList->setCurrentItem(item);
first = false;
}
}