本文整理汇总了C++中QStandardItem::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setText方法的具体用法?C++ QStandardItem::setText怎么用?C++ QStandardItem::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QStandardItem
QList<QStandardItem *> MainWindow::createrowinputtable(QFileInfo fileinfo)
{
QList<QStandardItem *>listitems;
qint64 fs;
QString strfs;
for(int col=0 ; col < inputmodel->columnCount() ; col++)
{
QStandardItem *item = new QStandardItem();
switch(col)
{
case 0:item->setText(fileinfo.fileName());
// add logs,constellations,signals,prns
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
addChildrentofile(item);
break;
case 1: fs = fileinfo.size();
strfs = convertintokbmbgb(fs);
item->setText(strfs);
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
break;
case 2: item->setFlags(item->flags() ^ Qt::ItemIsEditable); //initialize nof ascii logs
break;
case 3: item->setFlags(item->flags() ^ Qt::ItemIsEditable);// initialize no of binary logs
break;
case 4: item->setFlags(item->flags() ^ Qt::ItemIsEditable);//initialize no of unkonwn logs
break;
}
listitems.append(item);
}
return listitems;
}
示例2: addHttpNode
void AnalysisThread::addHttpNode(const ApplicationData* pad)
{
QStandardItem* httpitem = new QStandardItem();
QStringList contentList = pad->strContent.split("\r\n");
this->len = pad->strContent.size();
setUserRoleData(httpitem);
httpitem->setText("Hypertext Transfer Protocol");
QStandardItem* item;
foreach (QString contentitem, contentList)
{
if (contentitem == "")
{
continue;
}
item = new QStandardItem();
contentitem += "\\r\\n";
this->len = contentitem.size() - 2; // As \\r \\n each is two char
item->setText(contentitem);
setUserRoleData(item);
httpitem->appendRow(item);
this->offset += this->len;
}
this->model->setItem(this->irow++, 0, httpitem);
}
示例3: compare_one_download
void list_handling::compare_one_download(const download &new_download, const download &old_download, QStandardItem *pkg, int dl_line){
QStandardItem *dl;
if(old_download.id != new_download.id){
dl = pkg->child(dl_line, 0);
dl->setText(QString("%1").arg(new_download.id));
}
if(old_download.title != new_download.title){
dl = pkg->child(dl_line, 1);
dl->setText(QString(new_download.title.c_str()));
}
if(old_download.url != new_download.url){
dl = pkg->child(dl_line, 2);
dl->setText(QString(new_download.url.c_str()));
}
if((new_download.status != old_download.status) || (new_download.downloaded != old_download.downloaded) || (new_download.size != old_download.size) ||
(new_download.wait != old_download.wait) || (new_download.error != old_download.error) || (new_download.speed != old_download.speed)){
string color, status_text, time_left;
color = build_status(status_text, time_left, new_download);
dl = pkg->child(dl_line, 3);
dl->setText(QString(time_left.c_str()));
string colorstring = "img/bullet_" + color + ".png";
dl = pkg->child(dl_line, 4);
dl->setText(QString(my_main_window->CreateQString(status_text.c_str())));
dl->setIcon(QIcon(colorstring.c_str()));
}
}
示例4: foreach
foreach (QChar c, characters) {
// Write the table entries
QList<QStandardItem *> rowItems;
// Character
QStandardItem *item = new QStandardItem();
item->setText(QString(c));
rowItems << item;
// Decimal number
item = new QStandardItem();
ushort char_number = c.unicode();
item->setText(QString::number(char_number));
rowItems << item;
// Hex number
item = new QStandardItem();
QString hexadecimal;
hexadecimal.setNum(char_number,16);
item->setText(hexadecimal.toUpper());
rowItems << item;
// Name
item = new QStandardItem();
item->setText(XMLEntities::instance()->GetEntityName(char_number));
rowItems << item;
// Description
item = new QStandardItem();
item->setText(XMLEntities::instance()->GetEntityDescription(char_number));
rowItems << item;
for (int i = 0; i < rowItems.count(); i++) {
rowItems[i]->setEditable(false);
}
m_ItemModel->appendRow(rowItems);
}
示例5: setDefaultEvent
void CommonEventsDatas::setDefaultEvent(QStandardItemModel* model,
QStringList& namesEvents,
QList<QVector<SystemCreateParameter*>>&
parameters)
{
QStandardItemModel* modelParameters;
QList<QStandardItem*> row;
SystemEvent* ev;
QStandardItem* item;
for (int i = 0; i < namesEvents.size(); i++){
modelParameters = new QStandardItemModel;
for (int j = 0; j < parameters[i].size(); j++){
row = parameters[i][j]->getModelRow();
modelParameters->appendRow(row);
}
item = new QStandardItem();
item->setText(SuperListItem::beginningText);
modelParameters->appendRow(item);
ev = new SystemEvent(i+1, namesEvents[i], modelParameters);
item = new QStandardItem;
item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(ev)));
item->setText(ev->toString());
model->appendRow(item);
}
}
示例6: set_option
//==================================================
// == Set An Option
void XSettingsModel::set_option(QString option, bool enabled, QString value)
{
//qDebug() << "set " << option << _loading;
if(_loading){
return;
}
//= Find item matching the "option"
QList<QStandardItem *>items = findItems(option, Qt::MatchExactly,C_OPTION);
//qDebug() << "opts" << items;
//TODO handle error if not found
if (items.size() == 0) {
outLog("set_option:setx called with INVALID option ["+option+"]");
return;
}
//= Get/update the "enabled" item in the same row
QStandardItem *eItem = item(items[0]->row(),C_ENABLED);
eItem->setText(enabled ? "1" : "0");
//= Get/update the "value" item in the same row
QStandardItem *vItem = item(items[0]->row(),C_VALUE);
vItem->setText(value);
set_row_bg(items[0]->row(), enabled ? QColor(200,255,200) : QColor(240,240,240));
//= Announce the change
//emit upx(option, enabled, value);
emit updated(get_fgfs_list());
}
示例7: ImportData
QStandardItemModel* Importer::ImportData()
{
QString current_path = QDir::currentPath() + "//" + datafilename();
QFile file(QDir::toNativeSeparators(current_path));
if(!file.open(QIODevice::ReadOnly)) {
QMessageBox::information(0, tr("Ошибка"), file.errorString());
qDebug() << "Error in open file: " + file.errorString();
}
QTextStream in(&file);
in.setCodec(QTextCodec::codecForName("IBM 866"));
QString line = in.readLine();
QStringList fields = line.split(separator());
QStandardItemModel *model = new QStandardItemModel(0, fields.count()+1);
model->setHorizontalHeaderLabels(fields);
// Заменяем заголовки столбцов
for (int i = 0; i < model->columnCount() - 1; i++)
{
QStandardItem *item = model->horizontalHeaderItem(i);
QString item_text = item->text();
if (item_text.compare(tr("ФИОТБН")) == 0) {
item->setText(tr("Отправитель"));
} else if (item_text.compare(tr("Кому")) == 0) {
item->setText(tr("Получатель"));
}
}
int last_col_idx = model->columnCount() - 1;
model->setHorizontalHeaderItem(last_col_idx, new QStandardItem(tr("Состояние")));
model->horizontalHeaderItem(last_col_idx)->setText(tr("Состояние"));
// model->setHorizontalHeaderItem(0, new QStandardItem(tr("ТБН")));
// model->setHorizontalHeaderItem(1, new QStandardItem(tr("Отправитель")));
// model->setHorizontalHeaderItem(4, new QStandardItem(tr("Получатель")));
// model->setHorizontalHeaderItem(12, new QStandardItem(tr("Состояние")));
while(!in.atEnd())
{
QString line = in.readLine();
QStringList fields = line.split(separator());
QStringListIterator it(fields);
QList<QStandardItem *> data;
while (it.hasNext())
{
data << new QStandardItem(it.next());
}
model->appendRow(data);
}
file.close();
return model;
}
示例8: setDefault
void CommonEventsDatas::setDefault(){
SystemCommonReaction* react;
SystemCommonObject* object;
SuperListItem* super;
QStandardItem* item;
// Events system
QStringList namesEventsSystem;
namesEventsSystem << "Time" << "Chronometer" << "KeyPress" << "KeyRelease";
QList<QVector<SystemCreateParameter*>> parametersSystem;
parametersSystem << QVector<SystemCreateParameter*>({
new SystemCreateParameter(1,"Interval",new PrimitiveValue(0)),
new SystemCreateParameter(2,"Repeat",new PrimitiveValue(true))});
parametersSystem << QVector<SystemCreateParameter*>({
new SystemCreateParameter(1,"Left",new PrimitiveValue(0))});
parametersSystem << QVector<SystemCreateParameter*>({
new SystemCreateParameter(1,"ID",new PrimitiveValue),
new SystemCreateParameter(2,"Repeat",new PrimitiveValue(false)),
new SystemCreateParameter(3,"Immediate Repeat",
new PrimitiveValue(false))});
parametersSystem << QVector<SystemCreateParameter*>({
new SystemCreateParameter(1,"ID",new PrimitiveValue)});
setDefaultEvent(m_modelEventsSystem, namesEventsSystem, parametersSystem);
// Events user
QStringList namesEventsUser;
namesEventsUser << "Hero action";
QList<QVector<SystemCreateParameter*>> parametersUser;
parametersUser << QVector<SystemCreateParameter*>({});
setDefaultEvent(m_modelEventsUser, namesEventsUser, parametersUser);
// States
super = new SuperListItem(1, "Normal");
item = new QStandardItem;
item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(super)));
item->setText(super->toString());
m_modelStates->appendRow(item);
// Common reactors
react = new SystemCommonReaction;
item = new QStandardItem;
item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(react)));
item->setText(react->toString());
m_modelCommonReactors->appendRow(item);
// Common objects
object = new SystemCommonObject;
object->setDefaultFirst();
item = new QStandardItem;
item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(object)));
item->setText(object->toString());
m_modelCommonObjects->appendRow(item);
object = new SystemCommonObject;
object->setDefaultHero(m_modelEventsSystem, m_modelEventsUser);
item = new QStandardItem;
item->setData(QVariant::fromValue(reinterpret_cast<quintptr>(object)));
item->setText(object->toString());
m_modelCommonObjects->appendRow(item);
}
示例9: setItems
void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
const QIcon &defaultIcon,
QStandardItemList &sl)
{
// Tooltip, mostly for icon view mode
QString firstTooltip = action->objectName();
const QString text = action->text();
if (!text.isEmpty()) {
firstTooltip += QLatin1Char('\n');
firstTooltip += text;
}
Q_ASSERT(sl.size() == NumColumns);
QStandardItem *item = sl[NameColumn];
item->setText(action->objectName());
QIcon icon = action->icon();
if (icon.isNull())
icon = defaultIcon;
item->setIcon(icon);
item->setToolTip(firstTooltip);
item->setWhatsThis(firstTooltip);
// Used
const QWidgetList associatedDesignerWidgets = associatedWidgets(action);
const bool used = !associatedDesignerWidgets.empty();
item = sl[UsedColumn];
item->setCheckState(used ? Qt::Checked : Qt::Unchecked);
if (used) {
QString usedToolTip;
const QString separator = QLatin1String(", ");
const int count = associatedDesignerWidgets.size();
for (int i = 0; i < count; i++) {
if (i)
usedToolTip += separator;
usedToolTip += associatedDesignerWidgets.at(i)->objectName();
}
item->setToolTip(usedToolTip);
} else {
item->setToolTip(QString());
}
// text
item = sl[TextColumn];
item->setText(action->text());
item->setToolTip(action->text());
// shortcut
const QString shortcut = actionShortCut(core, action).value().toString(QKeySequence::NativeText);
item = sl[ShortCutColumn];
item->setText(shortcut);
item->setToolTip(shortcut);
// checkable
sl[CheckedColumn]->setCheckState(action->isCheckable() ? Qt::Checked : Qt::Unchecked);
// ToolTip. This might be multi-line, rich text
QString toolTip = action->toolTip();
item = sl[ToolTipColumn];
item->setToolTip(toolTip);
item->setText(toolTip.replace(QLatin1Char('\n'), QLatin1Char(' ')));
}
示例10: QDialog
AcceptRIEXDialog::AcceptRIEXDialog (const QList<RIEXItem>& items,
QObject *entryObj, QString message, QWidget *parent)
: QDialog (parent)
, Model_ (new QStandardItemModel (this))
{
Ui_.setupUi (this);
Model_->setHorizontalHeaderLabels ({ tr ("Action"), tr ("ID"), tr ("Name"), tr ("Groups") });
for (const RIEXItem& item : items)
{
QList<QStandardItem*> row;
QStandardItem *action = new QStandardItem;
action->setCheckState (Qt::Checked);
action->setCheckable (true);
switch (item.Action_)
{
case RIEXItem::AAdd:
action->setText (tr ("add"));
break;
case RIEXItem::ADelete:
action->setText (tr ("delete"));
break;
case RIEXItem::AModify:
action->setText (tr ("modify"));
break;
default:
action->setText (tr ("(unknown)"));
break;
}
action->setData (QVariant::fromValue<RIEXItem> (item));
row << action;
row << new QStandardItem (item.ID_);
row << new QStandardItem (item.Nick_);
row << new QStandardItem (item.Groups_.join ("; "));
Model_->appendRow (row);
}
Ui_.ItemsTree_->setModel (Model_);
ICLEntry *entry = qobject_cast<ICLEntry*> (entryObj);
const QString& id = entry->GetEntryName ().isEmpty () ?
entry->GetHumanReadableID () :
entry->GetEntryName () + " (" + entry->GetHumanReadableID () + ")";
const QString& text = message.isEmpty () ?
tr ("%1 has suggested to modify your contact list:")
.arg (id) :
tr ("%1 has suggested to modify your contact list:\n%2")
.arg (id)
.arg (message);
Ui_.MessageLabel_->setText (text);
}
示例11: on_setGPLogDir
void MainWindow::on_setGPLogDir(QString dirname)
{
if ( dirname.isEmpty() )
{
qDebug() << "No dir is selected \n Using Current Directory";
_strLogDir = QDir::currentPath();
}
else
{
_strLogDir = dirname;
}
qDebug() << "Directory " << _strLogDir << " selected";
// clear old model
_modelGenerations->clear();
// initialize view header
QStringList generationList;
generationList.append("generation milestone");
_modelGenerations->setHorizontalHeaderLabels(generationList);
QDir qDir(_strLogDir);
QStringList filters;
// set generations' files
// get the largest generation
filters << "beagle_g?.obm";
QStringList entries = qDir.entryList(filters);
for( int i = 0; i < entries.size(); i++ ) {
QStandardItem * item = new QStandardItem;
item->setText(entries.at(i));
_modelGenerations->appendRow(item);
}
filters.clear();
filters << "beagle_g??.obm";
entries = qDir.entryList(filters);
for( int i = 0; i < entries.size(); i++ ) {
QStandardItem * item = new QStandardItem;
item->setText(entries.at(i));
_modelGenerations->appendRow(item);
}
filters.clear();
filters << "beagle_g???.obm";
entries = qDir.entryList(filters);
for( int i = 0; i < entries.size(); i++ ) {
QStandardItem * item = new QStandardItem;
item->setText(entries.at(i));
_modelGenerations->appendRow(item);
}
// set log file
//setLogFile(_strLogDir + "/beagle.log");
}
示例12: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
CameraAbilities a;
int size,r;
ui->setupUi(this);
QStandardItemModel *model = new QStandardItemModel(this);
model->setHorizontalHeaderItem(0, new QStandardItem(QString("Camera")));
model->setHorizontalHeaderItem(1, new QStandardItem(QString("Comment")));
ui->tableView->setModel(model);
GPContext* context = gp_context_new();
CameraAbilitiesList* list;
gp_abilities_list_new(&list);
gp_abilities_list_load(list, context);
size = gp_abilities_list_count(list);
for(int i= 0; i < size; i++)
{
r = gp_abilities_list_get_abilities(list, i, &a);
if( r < 0 ) break;
QStandardItem* cam = new QStandardItem(QString(a.model));
model->setItem(i,0, cam);
QStandardItem* com = new QStandardItem();
switch (a.status)
{
case GP_DRIVER_STATUS_TESTING:
com->setText(QString("TESTING"));
break;
case GP_DRIVER_STATUS_EXPERIMENTAL:
com->setText(QString("EXPERIMENTAL"));
break;
case GP_DRIVER_STATUS_DEPRECATED:
com->setText(QString("DEPRECATED"));
break;
case GP_DRIVER_STATUS_PRODUCTION:
break;
default:
com->setText(QString("UNKOWN"));
break;
}
model->setItem(i,1, com);
}
gp_abilities_list_free(list);
list = NULL;
gp_context_unref(context);
context = NULL;
}
示例13: populateModel
void CntImageEditorView::populateModel(QStandardItemModel *model)
{
QStandardItem *newPhoto = new QStandardItem();
newPhoto->setText(hbTrId("txt_phob_list_take_a_new_photo"));
newPhoto->setData(HbIcon("qtg_large_camera"), Qt::DecorationRole);
model->appendRow(newPhoto);
QStandardItem *fromGallery = new QStandardItem();
fromGallery->setText(hbTrId("txt_phob_list_chooce_from_gallery"));
fromGallery->setData(HbIcon("qtg_large_photos"), Qt::DecorationRole);
model->appendRow(fromGallery);
}
示例14: updateModel
void updateModel(QStandardItem* parentItem, ReflectableClass& object, Node* node, const std::string& propertyPrefix = "") {
vector<IClassProperty*> properties = object.getProperties();
for (unsigned i = 0, gridPos = 0; i < properties.size(); ++i) {
if (properties[i]->getAttribute<HideAttribute>())
continue;
QStandardItem* value = parentItem->child(gridPos, 1);
if (!value) {
string keyName = properties[i]->getName();
ShortNameAttribute* shortName = properties[i]->getAttribute<ShortNameAttribute>();
if (shortName)
keyName = keyName + " (" + shortName->getName() + ")";
QStandardItem* key = new QStandardItem(keyName.c_str());
value = new QStandardItem();
parentItem->setChild(gridPos, 0, key);
parentItem->setChild(gridPos, 1, value);
}
IReflectableAttribute* reflectable = properties[i]->getAttribute<IReflectableAttribute>();
if (reflectable) {
ReflectableClass* subObject = reflectable->getValuePtr(object, properties[i]);
// If the type of the reflectable object has changed, the subtree needs to be rebuild.
// You need to know the previous type in order to detect a change. ScalarAttributes are
// no longer supported in order to guarantee, that the string value is always set to the
// previous type name.
if (subObject) {
std::string oldClassName(value->text().toStdString());
if (oldClassName.compare(subObject->getClassName())) {
value->setText(subObject->getClassName().c_str());
buildModel(parentItem->child(gridPos, 0), subObject, node, propertyPrefix + properties[i]->getName() + ".");
} else {
updateModel(parentItem->child(gridPos, 0), *subObject, node, propertyPrefix + properties[i]->getName() + ".");
}
} else {
value->setText(properties[i]->getStringValue(object).c_str());
}
} else if (properties[i]->getAttribute<FlagAttribute>()) {
ClassProperty<bool>* boolProperty = dynamic_cast<ClassProperty<bool>* >(properties[i]);
// properties tagged as Flag() must be of type bool
assert(boolProperty);
if (boolProperty->getValue(object))
value->setCheckState(Qt::Checked);
else
value->setCheckState(Qt::Unchecked);
} else{
value->setText(properties[i]->getStringValue(object).c_str());
}
++gridPos;
}
}
示例15:
QList<QStandardItem *> SystemMonsterTroop::getModelRow() const{
QList<QStandardItem*> row = QList<QStandardItem*>();
QStandardItem* itemID = new QStandardItem;
QStandardItem* itemLevel = new QStandardItem;
itemID->setData(QVariant::fromValue(reinterpret_cast<quintptr>(this)));
itemID->setText(toString());
itemLevel->setText(QString::number(m_level));
row.append(itemID);
row.append(itemLevel);
return row;
}