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


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

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


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

示例1:

void Widget3D::show_hide_actor(QListWidgetItem * itemDuble){

  itemDuble->setSelected(true);

  bool visible = m_source_list.at(m_actor_list->row(itemDuble))->getRepresentation(this->m_RenderView)->isVisible();

  for(int i=0;i<m_actor_list->selectedItems().size();++i)
  {
      QListWidgetItem * item = m_actor_list->selectedItems().at(i);

      //if actor is visible
      if(visible){
        //Hide actor/region : Change icon and text color
        item->setTextColor(Qt::gray);
        item->setIcon(QIcon(":/paraview_icons/pqEyeballd16.png"));
      }else{
        //Show actor/region : Change icon and text color
        item->setTextColor(Qt::black);
        item->setIcon(QIcon(":/paraview_icons/pqEyeball16.png"));
      }

      //Set actor/region visibility
      m_source_list.at(m_actor_list->selectionModel()->selectedRows().at(i).row())
          ->getRepresentation(this->m_RenderView)->setVisible(!visible);

  }

  //be sure the mesh is updated
  m_RenderView->getWidget()->update();
  reset_camera();

}
开发者ID:Ivor23,项目名称:coolfluid3,代码行数:32,代码来源:Widget3D.cpp

示例2: OnLog

Void CViewLog::OnLog( UInt32 lvl, String header, String msg )
{
	Char out[1024];

	if( header )
		Sb::StringSetFormattedText(out, 1024, "%s - %s", header, msg );
	else
		Sb::StringSetFormattedText(out, 1024, "%s", msg );

	QListWidgetItem* item = new QListWidgetItem( out );

	if( lvl == Sb::CLogger::nLevel_Info )
	{
        item->setTextColor( QColor( 40,40,40 ) );
	}
	else if( lvl == Sb::CLogger::nLevel_Warning )
	{
		item->setTextColor( QColor( 255, 127, 0 ) );
	}
	else if( lvl == Sb::CLogger::nLevel_Error )
	{
		item->setTextColor( QColor( 255, 0, 0 ) );
	}
	
	m_TextOutput->addItem( item );
	m_TextOutput->scrollToItem( item );
}
开发者ID:ClementVidal,项目名称:sable.dune,代码行数:27,代码来源:Log.cpp

示例3: QListWidgetItem

BOOST_FOREACH( std::list< qt4::QMessage>::const_reference message, messageList ) {
		QListWidgetItem *item = new QListWidgetItem();
		std::stringstream logStream;
		logStream << message.m_module << "(" << message.time_str << ") -> " << message.message ;
		item->setText( logStream.str().c_str() );

		switch ( message.m_level ) {
		case error:

			if( m_Interface.errorCheck->checkState() == Qt::Checked ) {
				item->setTextColor( Qt::red );
				m_Interface.logList->addItem( item );
			}

			break;
		case warning:

			if( m_Interface.warningCheck->checkState() == Qt::Checked ) {
				item->setTextColor( QColor( 218, 165, 32 ) );
				m_Interface.logList->addItem( item );
			}

			break;
		case info:

			if( m_Interface.infoCheck->checkState() == Qt::Checked ) {
				item->setTextColor( Qt::darkBlue );
				m_Interface.logList->addItem( item );
			}

			break;
		case verbose_info:

			if( m_Interface.verboseCheck->checkState() == Qt::Checked ) {
				item->setTextColor( Qt::black );
				m_Interface.logList->addItem( item );
			}

			break;
		case notice:

			if( m_Interface.noticeCheck->checkState() == Qt::Checked ) {
				item->setTextColor( QColor( 34, 139, 34 ) );
				m_Interface.logList->addItem( item );
			}

			break;
		}

	}
开发者ID:hanke,项目名称:vast,代码行数:50,代码来源:loggingDialog.cpp

示例4: pairingDone

void DeviceDiscoveryDialog::pairingDone(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing)
{
    QList<QListWidgetItem *> items = ui->list->findItems(address.toString(), Qt::MatchContains);

    if (pairing == QBluetoothLocalDevice::Paired || pairing == QBluetoothLocalDevice::AuthorizedPaired ) {
        for (int var = 0; var < items.count(); ++var) {
            QListWidgetItem *item = items.at(var);
            item->setTextColor(QColor(Qt::green));
        }
    } else {
        for (int var = 0; var < items.count(); ++var) {
            QListWidgetItem *item = items.at(var);
            item->setTextColor(QColor(Qt::red));
        }
    }
}
开发者ID:kaltsi,项目名称:qt-mobility,代码行数:16,代码来源:device.cpp

示例5: addDevice

void DeviceDiscoveryDialog::addDevice(const QBluetoothDeviceInfo &info)
{
    QString label = QString("%1 %2").arg(info.address().toString()).arg(info.name());
    QList<QListWidgetItem *> items = ui->list->findItems(label, Qt::MatchExactly);
    if(items.empty()) {
        QListWidgetItem *item = new QListWidgetItem(label);
        QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(info.address());
        if (pairingStatus == QBluetoothLocalDevice::Paired || pairingStatus == QBluetoothLocalDevice::AuthorizedPaired )
            item->setTextColor(QColor(Qt::green));
        else
            item->setTextColor(QColor(Qt::black));

        ui->list->addItem(item);
    }

}
开发者ID:kaltsi,项目名称:qt-mobility,代码行数:16,代码来源:device.cpp

示例6: on_pushButton_clicked

void Dialog::on_pushButton_clicked()
{
    QListWidgetItem *itm = ui->listWidget->currentItem();
    itm->setText("Fuzzy bunny");
    itm->setTextColor(Qt::cyan);
    itm->setBackgroundColor(Qt::black);
}
开发者ID:ggurbet,项目名称:qtexamples,代码行数:7,代码来源:dialog.cpp

示例7: onADBErrorReadyRead

//----------------------------------------------------
void MainWindow::onADBErrorReadyRead()
{
	QProcess* process = (QProcess*) QObject::sender();

	QByteArray stdErr = process->readAllStandardError();
	QString stdErrLine = QString(stdErr).trimmed();

	if (stdErrLine.contains("device not found"))
	{
		mServiceShouldRun = false;
		QMessageBox::critical(this, "Device not found or unplugged", "Cannot find an Android device connected via ADB. Make sure USB Debugging is enabled on your device, and that the ADB drivers are installed. Follow the guide on our website for more information.");
	}
	else if (stdErrLine.contains("device offline")) 
	{
		mServiceShouldRun = false;
		QMessageBox::critical(this, "Device offline", "An Android device is connected but reports as offline. Check your device for any additional information, or try to unplug and replug your device");
	}
	else if (stdErrLine.contains("unauthorized"))
	{
		mServiceShouldRun = false;
		QMessageBox::critical(this, "Device unauthorized", "An Android device is connected but reports as unauthorized. Please check the confirmation dialog on your device.");
	}

	if (!stdErrLine.isEmpty())
	{
		mADBErrorLog.push_back(stdErrLine);

		if (mDebugWidget != nullptr)
		{
			QListWidgetItem* item = new QListWidgetItem(stdErrLine);
			item->setTextColor(QColor(255, 0, 0));
			mDebugWidget->addItem(item);
		}
	}
}
开发者ID:NickVanderPyle,项目名称:bbqscreen_client,代码行数:36,代码来源:mainwindow.cpp

示例8: startElement

bool AnnotationConfigurationHandler::startElement( 
    const QString & /* namespaceURI */,
    const QString & /* localName */,
    const QString &qName,
    const QXmlAttributes &attributes )
{
  if ( !metAnnotationConfigurationTag && qName != "annotationConfiguration" )
  {
    errorStr = QObject::tr( "The file is not an Annotation Configuration file." );
    return false;
  }

  if ( qName == "annotationConfiguration" )
  {
    metAnnotationConfigurationTag = true;
  }
  else if ( qName == "entity" )
  {
    QListWidgetItem *item = new QListWidgetItem(listWidget);
    item->setFlags( item->flags() | Qt::ItemIsEditable );
    if (m_isEditor)
    {
      item->setFlags( item->flags() | Qt::ItemIsUserCheckable);
    }
    item->setText( attributes.value( "name" ) );
    QColor color( attributes.value( "color" ) );
    QColor white( Qt::white );
    QBrush brush( color );
    
    colors->push_back( QColor( attributes.value( "color" ).toLower() ) );
    (*colorNames2EntityTypes)[attributes.value( "color" ).toLower()] = attributes.value( "name" );
    /// @todo setBackgroundColor is deprecated in QT 4.2, replace by
    /// setBackground below after upgrading.
    /// item->setBackgroundColor  ( QColor( attributes.value( "color" ) ) );
    if (attributes.value("recursive") == "true")
    {
      m_recursiveEntityTypes->push_back(attributes.value( "name" ));
      QFont font = item->font();
      font.setItalic(true);
      font.setBold(true);
      item->setFont(font);
      if (m_isEditor)
      {
        item->setCheckState(Qt::Checked);
      }
    }
    else
    {
      if (m_isEditor)
      {
        item->setCheckState(Qt::Unchecked);
      }
    }
    item->setBackground  ( brush );
    item->setTextColor  ( white );
  }

  return true;
}
开发者ID:FaizaGara,项目名称:lima,代码行数:59,代码来源:annotationConfigurationHandler.cpp

示例9:

void Class20::on_pushButton_clicked()
{
	//ui.listWidget->currentItem()->setText("Busy Boy");
	QListWidgetItem *itm = ui.listWidget->currentItem();
	itm->setText("Busy Boy");
	itm->setTextColor(Qt::red);
	itm->setBackgroundColor(Qt::black);
}
开发者ID:PeterRoll,项目名称:QtLearning,代码行数:8,代码来源:class20.cpp

示例10:

void MyDialog::on_pushButton_2_clicked()
{
    //ui->listWidget->currentItem()->setText("Fussy");
    QListWidgetItem *item = ui->listWidget->currentItem();
    item->setText("Fussy bunny");
    item->setTextColor(Qt::red);
    item->setBackground(Qt::black);
}
开发者ID:thomasalvatran,项目名称:Notepad,代码行数:8,代码来源:mydialog.cpp

示例11: addItem

//-----------------------------------------------------------------------------------------------------------------------------
void Console::addItem(QString texte, QColor couleur, bool gras)
{
    QListWidgetItem *item = new QListWidgetItem(texte);
    QFont grasFont;
    grasFont.setBold(gras);
    item->setFont(grasFont);
    item->setTextColor(couleur);
    liste->addItem(item);

    emit newItem(liste->item(liste->count()-1));
}
开发者ID:maidmaid,项目名称:maiday,代码行数:12,代码来源:console.cpp

示例12: on_pushButton_clicked

void Dialog::on_pushButton_clicked()
{
    // create a pointer to the current item..
    // easier than writing this code over and over again
    // D.R.Y. !!
    QListWidgetItem *item = ui->listWidget->currentItem();

    // plethora of things you can do with the list widget item
    // QListWidgetItem is a class from the QListWidget class
    item->setText("Chubby Bunny");
    item->setTextColor(Qt::white);
    item->setBackgroundColor(Qt::black);
}
开发者ID:TravisAvey,项目名称:AdvCpp,代码行数:13,代码来源:dialog.cpp

示例13: onClickShowDebugLog

//----------------------------------------------------
void MainWindow::onClickShowDebugLog()
{
	if (mDebugWidget != nullptr) {
		delete mDebugWidget;
	}
	mDebugWidget = new QListWidget();
	mDebugWidget->addItems(mADBLog);

	for (auto it = mADBErrorLog.begin(); it != mADBErrorLog.end(); ++it) {
		QListWidgetItem* item = new QListWidgetItem(*it);
		item->setTextColor(QColor(255, 0, 0));
		mDebugWidget->addItem(item);
	}

	mDebugWidget->show();
}
开发者ID:NickVanderPyle,项目名称:bbqscreen_client,代码行数:17,代码来源:mainwindow.cpp

示例14: FillList

void ezQtDataDirsDlg::FillList()
{
  if (m_Config.m_DataDirs.IsEmpty())
    m_iSelection = -1;

  if (m_iSelection != -1)
    m_iSelection = ezMath::Clamp<ezInt32>(m_iSelection, 0, m_Config.m_DataDirs.GetCount() - 1);

  ListDataDirs->blockSignals(true);

  ListDataDirs->clear();

  for (auto dd : m_Config.m_DataDirs)
  {
    QListWidgetItem* pItem = new QListWidgetItem(ListDataDirs);
    pItem->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable /*| Qt::ItemFlag::ItemIsUserCheckable*/);

    QString sPath = QString::fromUtf8(dd.m_sDataDirSpecialPath.GetData());

    pItem->setText(sPath);
    ListDataDirs->addItem(pItem);

    if (dd.m_bHardCodedDependency)
    {
      QColor col;
      col.setNamedColor("Orange");
      pItem->setTextColor(col);
      pItem->setToolTip("This data directory is a hard dependency and cannot be removed.");
      pItem->setData(Qt::UserRole + 1, false); // can remove ?
    }
    else
    {
      pItem->setData(Qt::UserRole + 1, true); // can remove ?
    }
  }

  ListDataDirs->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);

  if (m_iSelection == -1)
    ListDataDirs->clearSelection();
  else
    ListDataDirs->setItemSelected(ListDataDirs->item(m_iSelection), true);

  ListDataDirs->blockSignals(false);

  on_ListDataDirs_itemSelectionChanged();
}
开发者ID:ezEngine,项目名称:ezEngine,代码行数:47,代码来源:DataDirsDlg.cpp

示例15: addListWidgetItems

void TikzCommandInserter::addListWidgetItems(QListWidget *listWidget, const TikzCommandList &commandList, bool addChildren)
{
	QFont titleFont = qApp->font();
	titleFont.setBold(true);
//	QColor titleBg(QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::Highlight));
//	titleBg = titleBg.lighter(120);
	QColor titleBg(QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::Window));
	titleBg = titleBg.darker(200);
	QColor titleFg(QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::HighlightedText));
	QColor separatorBg(QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::AlternateBase));
	if (separatorBg == QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::Base))
		separatorBg = separatorBg.darker(110);

	for (int i = 0; i < commandList.commands.size(); ++i)
	{
		if (commandList.commands.at(i).type == -1) // if we have an empty command corresponding to a submenu, then don't add the command, the submenus will be added later
			continue;

		QListWidgetItem *item = new QListWidgetItem(listWidget);
		QString itemText = commandList.commands.at(i).name;
		item->setText(itemText.remove('&'));

		if (itemText.isEmpty())
			item->setBackgroundColor(separatorBg);
		else
			item->setData(Qt::UserRole, commandList.commands.at(i).number); // link to the corresponding item in m_tikzCommandsList
	}

	if (!addChildren) return;

	for (int i = 0; i < commandList.children.size(); ++i)
	{
		QListWidgetItem *item = new QListWidgetItem(listWidget);
		QString itemText = commandList.children.at(i).title;
		item->setText(itemText.remove('&'));

		item->setBackgroundColor(titleBg);
		item->setTextColor(titleFg);
		item->setFont(titleFont);

		addListWidgetItems(listWidget, commandList.children.at(i));
	}
}
开发者ID:KarateSnowMachine,项目名称:qtikz-svn,代码行数:43,代码来源:tikzcommandinserter.cpp


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