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


C++ QTreeWidgetItem::setTextColor方法代码示例

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


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

示例1: addGrandChild

//Adds grandchild to item in CFDP tree
void Item::addGrandChild(int parent, int column, QString text)
{
    //Creates grandchild
    QTreeWidgetItem *newGrandchild = new QTreeWidgetItem();

    //Sets up grandchild based on parameters given to grandchild
    if(column == 0)
    {
        newGrandchild->setText(0, text);
        newGrandchild->setTextColor(0, white);
    }
    else if(column == 1)
    {
        newGrandchild->setText(1, "            " + text);
        newGrandchild->setTextColor(1, white);
    }
    else
    {
        newGrandchild->setText(0, text);
        newGrandchild->setText(1, "            " + text);
        newGrandchild->setTextColor(0, white);
        newGrandchild->setTextColor(1, white);
    }

    //Adds grandchild to its parent (child of top level item)
    children[parent]->addChild(newGrandchild);
}
开发者ID:Rileybrains,项目名称:BARCoMmS,代码行数:28,代码来源:item.cpp

示例2: read

//! [1]
int AdcListReader::read(QIODevice *device, QTreeWidgetItem **retVal)
{
    xml.setDevice(device);
    if (xml.readNextStartElement()) {
        QXmlStreamAttributes attr(xml.attributes());
        if (xml.name() == "FileListing" && attr.value("Version") == "1") {
            // Read extra metadata
            treeWidget->setProperty("generator", attr.value("Generator").toString().trimmed());
            treeWidget->setProperty("base", attr.value("Base").toString().trimmed());

            QTreeWidgetItem *topLevelNode = createChildItem(0, ShowListing::DirFileTree::RootType);
            topLevelNode->setBackgroundColor(0, QColor(240, 240, 255));
            topLevelNode->setTextColor(0, Qt::darkMagenta);
            topLevelNode->setText(0, attr.value("GeneratedDate").toString().trimmed() != "" ? QString("Date=%1").arg(attr.value("GeneratedDate").toString().trimmed()) : "");
            topLevelNode->setIcon(0, treeWidget->catalogIcon);
            topLevelNode->setData(1, Qt::UserRole, 0);

            readAdcList(topLevelNode);

            qulonglong totalSize = topLevelNode->data(1, Qt::UserRole).toLongLong();
            topLevelNode->setText(1, QString("[ %1 ]").arg(humanizeBigNums(totalSize, 2)));
            topLevelNode->setTextColor(1, getColorFromSize(totalSize));
            if (retVal) {
                *retVal = topLevelNode;
            }
        }
        else {
            xml.raiseError(QObject::tr("The file is not an ADC FileListing version 1 XML file. Found root element: %1")
                       .arg(xml.name().toString()));
        }
    }
    return xml.hasError();
}
开发者ID:mchubby,项目名称:qt_ShowListing,代码行数:34,代码来源:adclistreader.cpp

示例3: fillTree

//----------------------------------------------------------------------------------------
void OfsTreeWidget::fillTree(QTreeWidgetItem *pItem, std::string path)
{
    OFS::FileList list = mFile->listFiles(path.c_str(), OFS::OFS_DIR);

    std::sort(list.begin(), list.end(), OFS::FileEntry::Compare);

    for(unsigned int i = 0;i < list.size();i++)
    {
        Ogre::String name = list[i].name;

        QTreeWidgetItem* item = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString(name.c_str())));
        item->setIcon(0, mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::Folder));
        item->setTextColor(0, Qt::blue);

        std::string fullpath = path + name + "/";
        item->setWhatsThis(0, QString(fullpath.c_str()));

        if(mCapabilities & CAP_SHOW_COLORS)
        {
            bool isReadOnly = (list[i].flags & OFS::OFS_READONLY) > 0;
            bool isHidden = (list[i].flags & OFS::OFS_HIDDEN) > 0;

            QColor textColor = Qt::black;

            if(isReadOnly && isHidden)
                textColor = QColor(255, 210, 210);
            else if(isReadOnly)
                textColor = QColor(255, 0, 0);
            else if(isHidden)
                textColor = QColor(210, 210, 210);

             if(list[i].flags & OFS::OFS_LINK)
                 textColor.setBlue(255); 

            item->setTextColor(0, textColor);
        }

        pItem->addChild(item);

        mItemMap.insert(NameTreeWidgetMap::value_type(fullpath, item));


        fillTree(item, fullpath);
    }

    if(path != "/" && list.size() == 0)
    {
        QTreeWidgetItem* item = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString(".")));
        item->setTextColor(0, Qt::black);
        item->setWhatsThis(0, QString(path.c_str()));
        pItem->addChild(item);
    }
}
开发者ID:jacmoe,项目名称:ogitor,代码行数:54,代码来源:ofstreewidget.cpp

示例4: readDirectory

void AdcListReader::readDirectory(QTreeWidgetItem *item)
{
    QString pathParent = item ? item->data(0, Qt::UserRole).toString() : QDir::separator();
    QString filename = xml.attributes().value(sName).toString().trimmed();
    bool isConvOk = false;
    if (filename == "") {
        xml.raiseError(errorString(QObject::tr("Invalid Entry: <%1> has a missing or empty %2= attribute.")
                                   .arg(sDIRECTORY).arg(sName)));
        return;
    }

    QString filedate = xml.attributes().value(sDate).toString().trimmed();

    QTreeWidgetItem *folder = createChildItem(item, ShowListing::DirFileTree::DirType);
    folder->setIcon(0, treeWidget->folderIcon);
    folder->setData(0, Qt::UserRole, pathParent + QDir::separator() + filename);
    folder->setText(0, filename);
    folder->setData(1, Qt::UserRole, 0);

    if (xml.attributes().value("Incomplete").toString().trimmed() == "1") {
        folder->setTextColor(0, QColor(Qt::blue));
    }

    qulonglong filedateparsed = filedate.toLongLong(&isConvOk);
    if (isConvOk) {
        folder->setData(2, Qt::UserRole, filedateparsed);
    }


    while (!cancelRequested && !xml.hasError() && xml.readNextStartElement()) {
        // When a directory has been processed, notify listeners
        emit broadcastProgress(xml.device()->pos());
        if (xml.name() == sDIRECTORY)
            readDirectory(folder);
        else if (xml.name() == sFILE)
            readFile(folder);
        else
            xml.skipCurrentElement();
    }
    if (cancelRequested) {
        return;
    }


    qulonglong folderSize = folder->data(1, Qt::UserRole).toLongLong();
    folder->setText(1, QString(">> %1").arg(humanizeBigNums(folderSize, 2)));
    folder->setTextColor(1, getColorFromSize(folderSize));
    qulonglong parentsize = folderSize + item->data(1, Qt::UserRole).toLongLong();
    item->setData(1, Qt::UserRole, parentsize);
}
开发者ID:mchubby,项目名称:qt_ShowListing,代码行数:50,代码来源:adclistreader.cpp

示例5: onRefresh

/*! \brief Called when the Refresh button has been pressed */
bool ApplicationViewWidget::onRefresh()
{
    if(manager.busy()){
        return false;
    }

    std::vector<int> modulesIDs;
    std::vector<int> connectionsIDs;
    std::vector<int> resourcesIDs;

    for(int i=0;i<ui->moduleList->topLevelItemCount();i++){
        QTreeWidgetItem *it = ui->moduleList->topLevelItem(i);
        if(it->isSelected()){
            modulesIDs.push_back(it->text(1).toInt());
            it->setText(2,"waiting");
            it->setIcon(0,QIcon(":/images/progress_ico.png"));
            it->setTextColor(2,QColor("#000000"));
        }
    }


    for(int i=0;i<ui->connectionList->topLevelItemCount();i++){
        QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
        if(it->isSelected()){
            connectionsIDs.push_back(it->text(1).toInt());
            it->setText(2,"waiting");
            it->setIcon(0,QIcon(":/images/progress_ico.png"));
            it->setTextColor(2,QColor("#000000"));
        }
    }

    for(int i=0;i<ui->resourcesList->topLevelItemCount();i++){
        QTreeWidgetItem *it = ui->resourcesList->topLevelItem(i);
        if(it->isSelected()){
            resourcesIDs.push_back(it->text(1).toInt());
            it->setText(3,"waiting");
            it->setIcon(0,QIcon(":/images/progress_ico.png"));
            it->setTextColor(3,QColor("#000000"));
        }
    }

    manager.safeRefresh(modulesIDs,
                        connectionsIDs,
                        resourcesIDs);
    yarp::os::Time::delay(0.1);
    selectAllConnections(false);
    selectAllModule(false);
    selectAllResources(false);
}
开发者ID:JoErNanO,项目名称:qtyarp,代码行数:50,代码来源:applicationviewwidget.cpp

示例6: onResUnAvailable

/*! \brief Called when a resource become unavaible
    \param which
*/
void ApplicationViewWidget::onResUnAvailable(int which)
{
    QTreeWidgetItem *it = ui->resourcesList->topLevelItem(which);
    if(it){
        it->setText(3,"unavailable");
        if(it->text(2) == "computer"){
            it->setIcon(0,QIcon(":/images/nores_ico.png"));
            it->setTextColor(3,QColor("#BF0303"));
        }else{
            it->setIcon(0,QIcon(":/images/port_unavail_ico.png"));
            it->setTextColor(3,QColor("#BF0303"));
        }
    }
    reportErrors();
}
开发者ID:JoErNanO,项目名称:qtyarp,代码行数:18,代码来源:applicationviewwidget.cpp

示例7: finishSetInRuleList

void ComplexActionDialog::finishSetInRuleList()
{
	int const column = 0;
	QTreeWidgetItem *item = new QTreeWidgetItem(ui->ruleTreeWidget);
	item->setText(column, QString::fromUtf8("] Завершить множество"));
	item->setTextColor(column, QColor(100, 100, 100));
}
开发者ID:Ashatta,项目名称:tools,代码行数:7,代码来源:complexActionDialog.cpp

示例8: orInRuleList

void ComplexActionDialog::orInRuleList()
{
	int const column = 0;
	QTreeWidgetItem *item = new QTreeWidgetItem(ui->ruleTreeWidget);
	item->setText(column, QString::fromUtf8("или"));
	item->setTextColor(column, QColor(100, 100, 255));
}
开发者ID:Ashatta,项目名称:tools,代码行数:7,代码来源:complexActionDialog.cpp

示例9: insertError

/**
 * Inserts an item with text \a failure to the listview. \a details will be shown
 * when double-clicking on the matching listitem.
 */
void UnitTestDialog::insertError(const QString& failure, const QString& details)
{
    QTreeWidgetItem* item = new QTreeWidgetItem(treeViewFailure);
    item->setText(0,failure);
    item->setTextColor(0, Qt::red);
    item->setData(0, Qt::UserRole, QVariant(details));
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:11,代码来源:UnitTestImp.cpp

示例10: QTreeWidget

CategoryWidget::CategoryWidget(QWidget *parent) : QTreeWidget(parent), d(new CategoryWidgetPrivate()) {
  connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(toggleItemState(QModelIndex)));
  connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
  // get elements from the element manager
  QStringList categories = ElementManager::instance()->categories();
  // create the category nodes
  QHash<QString, QTreeWidgetItem *> categoryNodes;
  foreach(QString category, categories) {
    QTreeWidgetItem *parent = 0;
    int numSections = category.count("/") + 1;
    for (int i = 0; i < numSections; ++i) {
      QString path = category.section("/", 0, i, QString::SectionSkipEmpty);
      if (!categoryNodes.contains(path)) {
        QTreeWidgetItem *node = new QTreeWidgetItem();
        if (parent == 0)
          this->addTopLevelItem(node);
        else
          parent->addChild(node);
        QString name = category.section("/", i, i, QString::SectionSkipEmpty);
        node->setText(0, qApp->translate("Categories", name.toUtf8()));
        node->setData(0, Qt::UserRole, name);
        node->setData(1, Qt::UserRole, path);
        // use bigger fonts for items at higher levels
        QFont font = node->font(0);
        font.setPointSize(font.pointSize() + 2 - qMin(i, 3));
        node->setFont(0, font);
        if (i >= 3)
          node->setTextColor(0, QColor(96, 96, 96));
        categoryNodes[path] = node;
      }
      parent = categoryNodes[path];
    }
  }
开发者ID:aavci1,项目名称:shopdesigner,代码行数:33,代码来源:CategoryWidget.cpp

示例11: ShowDLCode

void Debugger_Disasm::ShowDLCode()
{
	ui->displayListData->clear();
	ui->displayListData->setColumnWidth(0,70);

	u32 startPc = displayListRowSelected->data(2,Qt::UserRole).toInt();
	u32 curPc = displayListRowSelected->data(3,Qt::UserRole).toInt();

	std::map<int,std::string> data;
	FillDisplayListCmd(data, startPc,0);

	for(std::map<int,std::string>::iterator it = data.begin(); it != data.end(); it++)
	{
		QTreeWidgetItem* item = new QTreeWidgetItem();
		char temp[24];
		sprintf(temp,"%08x",it->first);
		item->setText(0,temp);
		item->setText(1,it->second.c_str());
		if(curPc == it->first)
		{
			for(int j = 0; j < 2; j++)
				item->setTextColor(j, Qt::green);
		}
		ui->displayListData->addTopLevelItem(item);
	}
}
开发者ID:Almamu,项目名称:ppsspp,代码行数:26,代码来源:debugger_disasm.cpp

示例12: initComplexAction

void ComplexActionDialog::initComplexAction(ComplexUserAction *complexUserAction, QTreeWidgetItem *item, const int &column)
{
	int const currentColumn = column;
	QList<UserAction *> userActions = complexUserAction->userActions();
	for (UserAction *userAction: userActions) {
		BaseUserAction *baseUserAction = dynamic_cast<BaseUserAction *>(userAction);
		if (baseUserAction != nullptr) {
			QTreeWidgetItem *baseActionItem = new QTreeWidgetItem(item);
			QString const userActionName = baseUserAction->userActionName();
			baseActionItem->setText(column, userActionName);
		}
		else {
			ComplexUserAction *newComplexUserAction = dynamic_cast<ComplexUserAction *>(userAction);
			if (newComplexUserAction != nullptr) {
				QTreeWidgetItem *complexActionItem = new QTreeWidgetItem(item);
				complexActionItem->setText(currentColumn, newComplexUserAction->userActionName());
				initComplexAction(newComplexUserAction, complexActionItem, currentColumn);
			}
			else if (reserveRuleItems.contains(userAction->userActionName())) {
				int blue = 100;
				if (userAction->userActionName() == QString::fromUtf8("или")) {
					blue = 255;
				}
				QTreeWidgetItem *redTapeInstructionItem = new QTreeWidgetItem(item);
				redTapeInstructionItem->setText(currentColumn, userAction->userActionName());
				redTapeInstructionItem->setTextColor(currentColumn, QColor(100, 100, blue));
			}
		}
	}
}
开发者ID:Ashatta,项目名称:tools,代码行数:30,代码来源:complexActionDialog.cpp

示例13: updateGameStatsFromJsonResponse

void dialogGameStats::updateGameStatsFromJsonResponse(const QJsonObject &jsonObject) {

    if (!jsonObject["top"].isNull()) {



            for(QJsonObject::const_iterator iter = jsonObject.begin(); iter != jsonObject.end(); ++iter) {
                if (iter.key() == "top")
                {

                   // while (this->ui->tableWidgetGameStats->rowCount() > 0)
                   // {
                   //     this->ui->tableWidgetGameStats->removeRow(0);
                   // }

                    this->ui->treeWidgetGameStats->clear();

                    //this->ui->tableWidgetGameStats->setColumnCount(2);
                   // this->ui->tableWidgetGameStats->horizontalHeaderItem(0)->setText("Viewers");
                   // this->ui->tableWidgetGameStats->horizontalHeaderItem(1)->setText("Game");


                    for (int i = 0; i <= iter.value().toArray().size(); i++)
                    {
                   // qDebug() << iter.value().toArray().at(i).toObject()["game"].toObject()["name"].toString();
                   // qDebug() <<  iter.value().toArray().at(i).toObject()["viewers"].toDouble();


                    if (iter.value().toArray().at(i).toObject()["game"].toObject()["name"].toString() != "") {
                        QTreeWidgetItem * item = new QTreeWidgetItem();
                        item->setText(0,QString::number(i+1));
                        item->setText(1,QString::number(iter.value().toArray().at(i).toObject()["viewers"].toDouble()));
                        item->setText(2,iter.value().toArray().at(i).toObject()["game"].toObject()["name"].toString());
                        item->setTextColor(1,  QColor(85,85,255));


                        this->ui->treeWidgetGameStats->addTopLevelItem(item);

                    }





                    }







                }
            }



        }

}
开发者ID:Galbi3000,项目名称:twitcher,代码行数:60,代码来源:dialoggamestats.cpp

示例14: onDisconnect

/*! \brief Called when the Disconnect button has been pressed */
bool ApplicationViewWidget::onDisconnect()
{
    if(manager.busy()){
        return false;
    }


    std::vector<int> MIDs;
    for(int i=0;i<ui->connectionList->topLevelItemCount();i++){
        QTreeWidgetItem *it = ui->connectionList->topLevelItem(i);
        if(it->isSelected()){
            MIDs.push_back(it->text(1).toInt());
            manager.updateConnection(it->text(1).toInt(),
                                     it->text(3).toLatin1().data(),
                                     it->text(4).toLatin1().data(),
                                     it->text(5).toLatin1().data());

            it->setText(2,"waiting");
            it->setIcon(0,QIcon(":/images/progress_ico.png"));
            it->setTextColor(2,QColor("#000000"));

        }
    }


    manager.safeDisconnect(MIDs);
    yarp::os::Time::delay(0.1);
    selectAllConnections(false);
    return true;
}
开发者ID:JoErNanO,项目名称:qtyarp,代码行数:31,代码来源:applicationviewwidget.cpp

示例15: AddItems

void ImportedBookmarksPreviewDialog::AddItems()
{
    const int rootFolderIntId = (elist->importSource == ImportedEntityList::Source_Firefox ? 1 : 0);
    ui->chkRemoveImportedFile->setVisible(elist->importSource == ImportedEntityList::Source_Files);
    ui->chkRemoveImportedFile->setChecked(elist->removeImportedFiles);

    int index = 0;
    foreach (const ImportedBookmarkFolder& ibf, elist->ibflist)
    {
        QTreeWidgetItem* twi = new QTreeWidgetItem();
        twi->setText(0, ibf.title);
        twi->setIcon(0, icon_folder);
        twi->setData(0, TWID_IsFolder, true);
        twi->setData(0, TWID_Index, index);
        folderItems[ibf.intId] = twi;
        index++;

        //On Firefox, files and Urls, don't add or show the root folder.
        if (ibf.intId == rootFolderIntId && (elist->importSource == ImportedEntityList::Source_Firefox ||
                                             elist->importSource == ImportedEntityList::Source_Files ||
                                             elist->importSource == ImportedEntityList::Source_Urls))
            continue;

        if (ibf.parentId <= rootFolderIntId)
            ui->twBookmarks->addTopLevelItem(twi);
        else
            folderItems[ibf.parentId]->addChild(twi);
    }

    index = 0;
    foreach (const ImportedBookmark& ib, elist->iblist)
    {
        QTreeWidgetItem* twi = new QTreeWidgetItem();
        twi->setText(0, ib.title);
        SetBookmarkItemIcon(twi, ib);
        twi->setToolTip(0, ib.uri);
        twi->setData(0, TWID_IsFolder, false);
        twi->setData(0, TWID_Index, index);
        bookmarkItems[ib.intId] = twi;
        index++;

        if (ib.title.trimmed().isEmpty())
        {
            //For [title-less bookmarks] show their url in a different formatting.
            twi->setText(0, Util::FullyPercentDecodedUrl(ib.uri));
            twi->setTextColor(0, QColor(192, 128, 0));
            QFont italicFont = twi->font(0);
            italicFont.setItalic(true);
            twi->setFont(0, italicFont);
        }

        if (ib.parentId <= 0)
            ui->twBookmarks->addTopLevelItem(twi);
        else
            folderItems[ib.parentId]->addChild(twi);
    }

    ui->twBookmarks->expandAll();
    ui->twBookmarks->setCurrentItem(ui->twBookmarks->topLevelItem(0));
}
开发者ID:hossein,项目名称:BookmarkManager,代码行数:60,代码来源:ImportedBookmarksPreviewDialog.cpp


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