本文整理汇总了C++中QStandardItem::setTextAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setTextAlignment方法的具体用法?C++ QStandardItem::setTextAlignment怎么用?C++ QStandardItem::setTextAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::setTextAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refresh
void NetworkUsageWindow::refresh()
{
for (int i = 0; i < TOTAL_COUNTERS; i++)
{
DataCounters::CounterType counter = (DataCounters::CounterType) i;
QString counterLabel;
switch (counter)
{
case DataCounters::Messages:
counterLabel = "Messages";
break;
case DataCounters::MessageBytes:
counterLabel = "Messages bytes";
break;
case DataCounters::ImageBytes:
counterLabel = "Images bytes";
break;
case DataCounters::VideoBytes:
counterLabel = "Videos bytes";
break;
case DataCounters::AudioBytes:
counterLabel = "Audio bytes";
break;
case DataCounters::ProfileBytes:
counterLabel = "Profile pictures bytes";
break;
case DataCounters::SyncBytes:
counterLabel = "Synchronization bytes";
break;
case DataCounters::ProtocolBytes:
counterLabel = "Protocol bytes";
break;
case DataCounters::Total:
counterLabel = "Total bytes";
break;
}
int column = 0;
QStandardItem *item = new QStandardItem(counterLabel);
model->setItem(i, column++, item);
item->setSelectable(false);
qint64 bytes = Client::dataCounters.getReceivedBytes(i);
QString str = (i > 0) ? Utilities::formatBytes(bytes)
: QString::number(bytes);
item = new QStandardItem(str);
item->setSelectable(false);
item->setTextAlignment(Qt::AlignCenter);
model->setItem(i, column++, item);
bytes = Client::dataCounters.getSentBytes(i);
str = (i > 0) ? Utilities::formatBytes(bytes)
: QString::number(bytes);
item = new QStandardItem(str);
item->setSelectable(false);
item->setTextAlignment(Qt::AlignCenter);
model->setItem(i, column++, item);
}
}
示例2: bookmarkModel
void OnyxMainWindow::bookmarkModel(QStandardItemModel & model,
QModelIndex & selected)
{
CRFileHistRecord * rec = view_->getDocView()->getCurrentFileHistRecord();
if ( !rec )
return;
LVPtrVector<CRBookmark> & list( rec->getBookmarks() );
model.setColumnCount(2);
int row = 0;
for(int i = 0; i < list.length(); ++i)
{
// skip cites
CRBookmark * bmk = list[i];
if (!bmk || (bmk->getType() == bmkt_comment || bmk->getType() == bmkt_correction))
continue;
QString t =cr2qt(view_->getDocView()->getPageText(true, list[i]->getBookmarkPage()));
t.truncate(100);
QStandardItem *title = new QStandardItem(t);
title->setData((int)list[i]);
title->setEditable(false);
model.setItem(row, 0, title);
int pos = list[i]->getPercent();
QString str(tr("%1"));
str = str.arg(pos);
QStandardItem *page = new QStandardItem(str);
page->setTextAlignment(Qt::AlignCenter);
page->setEditable(false);
model.setItem(row, 1, page);
row++;
}
}
示例3: updateChannelConfig
void ChannelConfigModel::updateChannelConfig(const SongFormat *currentFormat)
{
this->removeRows(0, this->rowCount());
this->currentFormat = currentFormat;
if(currentFormat == nullptr)
{
return;
}
this->setRowCount(currentFormat->Voices);
for (int i = 0; i < currentFormat->Voices; i++)
{
const std::string &voiceName = currentFormat->VoiceName[i];
QStandardItem *item = new QStandardItem(QString::fromStdString(voiceName));
QBrush b(currentFormat->VoiceIsMuted[i] ? Qt::red : Qt::green);
item->setBackground(b);
QBrush f(currentFormat->VoiceIsMuted[i] ? Qt::white : Qt::black);
item->setForeground(f);
item->setTextAlignment(Qt::AlignCenter);
item->setCheckable(false);
item->setCheckState(currentFormat->VoiceIsMuted[i] ? Qt::Unchecked : Qt::Checked);
this->setItem(i, 0, item);
}
}
示例4: populateTableModel
static void populateTableModel(QStandardItemModel *model)
{
enum { ItemCount = 50 };
const char *itemNames[] = { "potion", "ring", "amulet", "wand", "figurine" };
const char *itemColors[] = { "black", "white", "red", "mauve", "blue", "green",
"yellow", "ultramarine", "pink", "purple" };
for (int i = 0; i < ItemCount; ++i) {
QList<QStandardItem*> row;
QStandardItem *item;
item = new QStandardItem((i % 10 == 0) ? QString(itemNames[i / 10]) : QString());
item->setEditable(false);
row.append(item);
item = new QStandardItem(QString("%1 %2").arg(QString(itemColors[i % 10])).
arg(QString(itemNames[i / 10])));
item->setEditable(false);
row.append(item);
item = new QStandardItem(QString("%1 gold coins").arg(i * 10 + (i % 10) * 15 + 13));
item->setTextAlignment(Qt::AlignCenter); // the Maemo 5 design spec recommends this.
item->setEditable(false);
row.append(item);
model->appendRow(row);
}
}
示例5: clone
void tst_QStandardItem::clone()
{
QStandardItem item;
item.setText(QLatin1String("text"));
item.setToolTip(QLatin1String("toolTip"));
item.setStatusTip(QLatin1String("statusTip"));
item.setWhatsThis(QLatin1String("whatsThis"));
item.setSizeHint(QSize(64, 48));
item.setFont(QFont());
item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
item.setBackground(QColor(Qt::blue));
item.setForeground(QColor(Qt::green));
item.setCheckState(Qt::PartiallyChecked);
item.setAccessibleText(QLatin1String("accessibleText"));
item.setAccessibleDescription(QLatin1String("accessibleDescription"));
item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
QStandardItem *clone = item.clone();
QCOMPARE(clone->text(), item.text());
QCOMPARE(clone->toolTip(), item.toolTip());
QCOMPARE(clone->statusTip(), item.statusTip());
QCOMPARE(clone->whatsThis(), item.whatsThis());
QCOMPARE(clone->sizeHint(), item.sizeHint());
QCOMPARE(clone->font(), item.font());
QCOMPARE(clone->textAlignment(), item.textAlignment());
QCOMPARE(clone->background(), item.background());
QCOMPARE(clone->foreground(), item.foreground());
QCOMPARE(clone->checkState(), item.checkState());
QCOMPARE(clone->accessibleText(), item.accessibleText());
QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
QCOMPARE(clone->flags(), item.flags());
QVERIFY(!(*clone < item));
delete clone;
}
示例6: appendRow
void DialogActiveRunways::appendRow(QString airportCode, QString rwyCode, QStandardItemModel *model)
{
QList<QStandardItem*> row;
QStandardItem *spacer1 = new QStandardItem();
spacer1->setFlags(Qt::NoItemFlags);
spacer1->setTextAlignment(Qt::AlignCenter);
row.append(spacer1);
QStandardItem *spacer2 = new QStandardItem();
spacer2->setFlags(Qt::NoItemFlags);
spacer2->setTextAlignment(Qt::AlignCenter);
row.append(spacer2);
QStandardItem *airport = new QStandardItem(airportCode);
airport->setFlags(Qt::NoItemFlags);
airport->setTextAlignment(Qt::AlignCenter);
row.append(airport);
QStandardItem *runway = new QStandardItem(rwyCode);
runway->setFlags(Qt::NoItemFlags);
runway->setTextAlignment(Qt::AlignCenter);
row.append(runway);
QStandardItem *spacer3 = new QStandardItem();
spacer3->setFlags(Qt::NoItemFlags);
spacer3->setTextAlignment(Qt::AlignCenter);
row.append(spacer3);
QStandardItem *spacer4 = new QStandardItem();
spacer4->setFlags(Qt::NoItemFlags);
spacer4->setTextAlignment(Qt::AlignCenter);
row.append(spacer4);
QStandardItem *spacer5 = new QStandardItem();
spacer5->setFlags(Qt::NoItemFlags);
spacer5->setTextAlignment(Qt::AlignCenter);
row.append(spacer5);
model->appendRow(row);
createCenteredCheckbox(model->indexFromItem(spacer1));
createCenteredCheckbox(model->indexFromItem(spacer2));
createCenteredCheckbox(model->indexFromItem(spacer3));
createCenteredCheckbox(model->indexFromItem(spacer4));
}
示例7: QStandardItem
QStandardItem *ResultsTree::CreateLineNumberItem(const QString &linenumber)
{
QStandardItem *item = new QStandardItem();
item->setData(QVariant(linenumber.toULongLong()), Qt::DisplayRole);
item->setToolTip(linenumber);
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
item->setEditable(false);
return item;
}
示例8: loadOutline
static void loadOutline(miniexp_t outlineExp, int offset, QStandardItem* parent, const QHash< QString, int >& indexByName)
{
const int outlineLength = miniexp_length(outlineExp);
for(int outlineN = qMax(0, offset); outlineN < outlineLength; ++outlineN)
{
miniexp_t bookmarkExp = miniexp_nth(outlineN, outlineExp);
const int bookmarkLength = miniexp_length(bookmarkExp);
if(bookmarkLength <= 1 || !miniexp_stringp(miniexp_nth(0, bookmarkExp)) || !miniexp_stringp(miniexp_nth(1, bookmarkExp)))
{
continue;
}
const QString title = QString::fromUtf8(miniexp_to_str(miniexp_nth(0, bookmarkExp)));
QString destination = QString::fromUtf8(miniexp_to_str(miniexp_nth(1, bookmarkExp)));
if(!title.isEmpty() && !destination.isEmpty())
{
if(destination.at(0) == QLatin1Char('#'))
{
destination.remove(0,1);
bool ok = false;
int destinationPage = destination.toInt(&ok);
if(!ok)
{
if(indexByName.contains(destination))
{
destinationPage = indexByName[destination] + 1;
}
else
{
continue;
}
}
QStandardItem* item = new QStandardItem(title);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setData(destinationPage, Qt::UserRole + 1);
QStandardItem* pageItem = item->clone();
pageItem->setText(QString::number(destinationPage));
pageItem->setTextAlignment(Qt::AlignRight);
parent->appendRow(QList< QStandardItem* >() << item << pageItem);
if(bookmarkLength >= 3)
{
loadOutline(bookmarkExp, 2, item, indexByName);
}
}
}
}
}
示例9: updateHeader
void InstrumentTree::updateHeader()/*{{{*/
{
//update the patchList headers as well
QStandardItem* pid = new QStandardItem("");
QStandardItem* patch = new QStandardItem(tr("Select Patch"));
patch->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
_patchModel->setHorizontalHeaderItem(0, patch);
_patchModel->setHorizontalHeaderItem(1, pid);
setColumnHidden(1, true);
}/*}}}*/
示例10: initList
void DUsbList::initList(){
m_SelectedDev = "";
m_StandardItemModel->clear();
QStandardItem *standItem = new QStandardItem(s_EmptyString);
// standItem->setIcon(QIcon(":/ui/images/unselect.png"));
standItem->setTextAlignment(Qt::AlignCenter);
m_StandardItemModel->appendRow(standItem);
m_LastIndex = m_StandardItemModel->index(0,0);
this->setModel(m_StandardItemModel);
}
示例11: populateListModel
static void populateListModel(QStandardItemModel *model)
{
enum { ItemCount = 50 };
for (int i = 0; i < ItemCount; ++i) {
QStandardItem *item = new QStandardItem(QString("%1 coins").arg(i*12+5));
item->setTextAlignment(Qt::AlignCenter); // the Maemo 5 design spec recommends this.
item->setEditable(false); // prevent editing of the item
model->appendRow(item);
}
}
示例12: QDialog
Ui_pluginManagerWindow::Ui_pluginManagerWindow(QWidget* parent) : QDialog(parent)
{
UiPluginManager manager;
ui.setupUi(this);
QStandardItemModel *model = new QStandardItemModel();
QStandardItem *nameItem = new QStandardItem(tr("Name"));
QStandardItem *versionItem = new QStandardItem(tr("Version"));
QStandardItem *descItem = new QStandardItem(tr("Description"));
nameItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
versionItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
descItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
model->setHorizontalHeaderItem(0, nameItem);
model->setHorizontalHeaderItem(1, versionItem);
model->setHorizontalHeaderItem(2, descItem);
ui.pluginTableView->verticalHeader()->setVisible(false);
ui.pluginTableView->setModel(model);
connect(
ui.pluginTableView->selectionModel(),
SIGNAL(currentRowChanged(const QModelIndex, const QModelIndex)), this,
SLOT(pluginTableView_rowChanged(const QModelIndex, const QModelIndex)));
connect(ui.setDefaultButton, SIGNAL(clicked(bool)), this, SLOT(setDefaultButton_clicked(bool)));
connect(ui.enableAllButton, SIGNAL(clicked(bool)), this, SLOT(enableAllButton_clicked(bool)));
connect(ui.disableAllButton, SIGNAL(clicked(bool)), this, SLOT(disableAllButton_clicked(bool)));
connect(ui.moveUpButton, SIGNAL(clicked(bool)), this, SLOT(moveUpButton_clicked(bool)));
connect(ui.moveDownButton, SIGNAL(clicked(bool)), this, SLOT(moveDownButton_clicked(bool)));
fillVideoEncoderList(manager);
ui.pluginTableView->resizeColumnsToContents();
connect(
ui.pluginTableView->model(),
SIGNAL(itemChanged(QStandardItem*)), this,
SLOT(pluginTableView_itemChanged(QStandardItem*)));
}
示例13: QWidget
InterceptWidget::InterceptWidget(IntercepSource * source, QWidget *parent) :
QWidget(parent),
source(source)
{
currentBlockSource = NULL;
currentGui = NULL;
ui = new(std::nothrow) Ui::InterceptWidget;
if (ui == NULL) {
qFatal("Cannot allocate memory for Ui::InterceptWidget X{");
}
ui->setupUi(this);
packetsTable = new(std::nothrow) QTableView(this);
if (packetsTable == NULL) {
qFatal("Cannot allocate memory for QTableView X{");
}
QAbstractItemModel *old = packetsTable->model();
model = source->getModel();
packetsTable->setModel(model);
delete old;
packetsTable->setSelectionMode(QAbstractItemView::ContiguousSelection);
packetsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
packetsTable->verticalHeader()->setFont(RegularFont);
packetsTable->horizontalHeader()->setFont(RegularFont);
packetsTable->setColumnWidth(PayloadModel::TIMESPTAMP_COLUMN,TIMESTAMP_COLUMN_WIDTH);
packetsTable->setColumnWidth(PayloadModel::DIRECTION_COLUMN,25);
packetsTable->verticalHeader()->setDefaultSectionSize(20);
#if QT_VERSION >= 0x050000
packetsTable->horizontalHeader()->setSectionsMovable( false );
#else
packetsTable->horizontalHeader()->setMovable(true);
#endif
connect(packetsTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(onCurrentSelectedChanged(QModelIndex,QModelIndex)));
ui->listLayout->addWidget(packetsTable);
updateColumns();
sourceChoices << CHOOSE_TEXT << UDP_EXTERNAL_SOURCE_TEXT << TCP_EXTERNAL_SOURCE_TEXT << RAW_TCP_SOURCE_TEXT;
ui->blockSourceComboBox->addItems(sourceChoices);
ui->blockSourceComboBox->setCurrentIndex(0);
QStandardItem * item = qobject_cast<QStandardItemModel *>(ui->blockSourceComboBox->model())->item(0);
item->setEnabled( false );
item->setTextAlignment(Qt::AlignCenter);
item->setBackground(Qt::darkGray);
item->setForeground(Qt::white);
connect(ui->blockSourceComboBox, SIGNAL(currentIndexChanged(QString)), SLOT(onSourceChanged(QString)));
}
示例14: QDialog
SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
{
setWindowTitle("GetThingsDone settings");
settings_ = Settings::getInstance();
QVBoxLayout *vbox = new QVBoxLayout(this);
setLayout(vbox);
confirmDone_ = new QCheckBox("Confirm item removal", this);
confirmDone_->setCheckState(
(settings_->get("confirm-removal") != "") ? Qt::Checked
: Qt::Unchecked
);
vbox->addWidget(confirmDone_);
#ifdef Q_WS_MAEMO_5
selector_ = new QMaemo5ListPickSelector(this);
QStandardItemModel *model = new QStandardItemModel(0, 1, selector_);
for (int i = 5; i <= 120; i += 5) {
QStandardItem *item = new QStandardItem(QString("%1").arg(i));
item->setTextAlignment(Qt::AlignCenter);
item->setEditable(false);
model->appendRow(item);
}
selector_->setModel(model);
int minutes = settings_->get("pomodoro-time").toInt();
selector_->setCurrentIndex((minutes / 5) - 1); // _should_ work...
timeout_ = new QMaemo5ValueButton("Pomodoro timeout", this);
timeout_->setValueLayout(QMaemo5ValueButton::ValueBesideText);
timeout_->setPickSelector(selector_);
vbox->addWidget(timeout_);
setAttribute(Qt::WA_Maemo5AutoOrientation, true);
setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
#endif
connect(this, SIGNAL(finished(int)), this, SLOT(finishedSlot()));
}
示例15: streamItem
void tst_QStandardItem::streamItem()
{
QStandardItem item;
item.setText(QLatin1String("text"));
item.setToolTip(QLatin1String("toolTip"));
item.setStatusTip(QLatin1String("statusTip"));
item.setWhatsThis(QLatin1String("whatsThis"));
item.setSizeHint(QSize(64, 48));
item.setFont(QFont());
item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
item.setBackground(QColor(Qt::blue));
item.setForeground(QColor(Qt::green));
item.setCheckState(Qt::PartiallyChecked);
item.setAccessibleText(QLatin1String("accessibleText"));
item.setAccessibleDescription(QLatin1String("accessibleDescription"));
QByteArray ba;
{
QDataStream ds(&ba, QIODevice::WriteOnly);
ds << item;
}
{
QStandardItem streamedItem;
QDataStream ds(&ba, QIODevice::ReadOnly);
ds >> streamedItem;
QCOMPARE(streamedItem.text(), item.text());
QCOMPARE(streamedItem.toolTip(), item.toolTip());
QCOMPARE(streamedItem.statusTip(), item.statusTip());
QCOMPARE(streamedItem.whatsThis(), item.whatsThis());
QCOMPARE(streamedItem.sizeHint(), item.sizeHint());
QCOMPARE(streamedItem.font(), item.font());
QCOMPARE(streamedItem.textAlignment(), item.textAlignment());
QCOMPARE(streamedItem.background(), item.background());
QCOMPARE(streamedItem.foreground(), item.foreground());
QCOMPARE(streamedItem.checkState(), item.checkState());
QCOMPARE(streamedItem.accessibleText(), item.accessibleText());
QCOMPARE(streamedItem.accessibleDescription(), item.accessibleDescription());
QCOMPARE(streamedItem.flags(), item.flags());
}
}