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


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

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


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

示例1: searchFromItems

bool Tracker::searchFromItems(std::vector<item> * itemsToSearch, const int selectITEMS){
    bool found = 0;
    for(unsigned i = 0; i < itemsToSearch->size(); i++){
        if(searchLine->text().toStdString().compare((*itemsToSearch)[i].getName()) == 0){
            QString nameToAdd = filingIn(QString::fromStdString((*itemsToSearch)[i].getName()), 17);
            QString cateToAdd = filingIn(QString::fromStdString((*itemsToSearch)[i].getLabel()), 14);
            QString amountToAdd = QString::number((*itemsToSearch)[i].getAmount());
            QString _itemToAdd;

        if(selectITEMS == 0){
           _itemToAdd = nameToAdd + cateToAdd + "-" + amountToAdd;
        }
        else{
            _itemToAdd = nameToAdd + cateToAdd + "+" + amountToAdd;
        }
        QListWidgetItem * itemToAdd = new QListWidgetItem;
        itemToAdd->setText(_itemToAdd);
        itemToAdd->setFont(QFont("Monaco", 10, QFont::Bold));
        //std::cout<<itemToAdd->text().toStdString().c_str()<<std::endl;
        detailList->addItem(itemToAdd);

        QString _dateToAdd;
        _dateToAdd = QString::number((*itemsToSearch)[i].getDate().month) + "/" + QString::number((*itemsToSearch)[i].getDate().day) + "/" +QString::number((*itemsToSearch)[i].getDate().year);
        QListWidgetItem * dateToAdd = new QListWidgetItem;
        dateToAdd->setText(_dateToAdd);
        dateToAdd->setFont(QFont("Monaco", 10, QFont::Bold));
        //std::cout<<dateToAdd->text().toStdString().c_str()<<std::endl;
        detailList->addItem(dateToAdd);

        found = 1;
    }
 }
    return found;

}
开发者ID:ChangleLiang,项目名称:Expense-Tracker,代码行数:35,代码来源:mainwindow.cpp

示例2: setCurrentState

void TraceDock::setCurrentState(int index)
{
  // nothing to do
  if(index == state_)
    return;

  // update previous
  QListWidgetItem * item = trace_->item(state_);
  if(item) {
    QFont fnt = item->font();
    fnt.setWeight(QFont::Normal);
    item->setFont(fnt);
  }

  // update new current
  item = trace_->item(index);
  if(item) {
    QFont fnt = item->font();
    fnt.setWeight(QFont::Bold);
    item->setFont(fnt);
  }

  state_ = index;

  trace_->setCurrentRow(index);
  trace_->scrollToItem(trace_->item(index));
}
开发者ID:RCambier,项目名称:EmbeddedAndVerification,代码行数:27,代码来源:traceDock.cpp

示例3: onFilterTextChanged

/**
 * @brief Displays the list of available filters
 * @param text Current text in the filter line edit
 */
void FilterWidget::onFilterTextChanged(QString text)
{
    if (text.length() < 3) {
        m_list->hide();
        return;
    }

    int height = 0;
    m_list->clear();
    foreach (Filter *filter, m_filters) {
        if (!filter->accepts(text))
            continue;

        if ((filter->info() == MovieFilters::Title || filter->info() == ConcertFilters::Title || filter->info() == TvShowFilters::Title)
            && !m_activeFilters.contains(filter)) {
            filter->setText(tr("Title contains \"%1\"").arg(text));
            filter->setShortText(text);
        }

        if ((filter->info() == MovieFilters::Path)
            && !m_activeFilters.contains(filter)) {
            filter->setText(tr("Filename contains \"%1\"").arg(text));
            filter->setShortText(text);
        }

        QListWidgetItem *item = new QListWidgetItem(filter->text(), m_list);
        item->setData(Qt::UserRole, QVariant::fromValue(filter));
        item->setBackgroundColor(QColor(255, 255, 255, 200));
        m_list->addItem(item);
        height += m_list->sizeHintForRow(m_list->count()-1);
    }

    if (m_list->count() > 0) {
        QFont font;
        font.setPixelSize(2);

        QListWidgetItem *topItem = new QListWidgetItem("");
        topItem->setFont(font);
        topItem->setBackgroundColor(QColor(255, 255, 255, 200));
        m_list->insertItem(0, topItem);
        height += m_list->sizeHintForRow(0);

        QListWidgetItem *bottomItem = new QListWidgetItem("");
        bottomItem->setBackgroundColor(QColor(255, 255, 255, 200));
        bottomItem->setFont(font);
        m_list->addItem(bottomItem);
        height += m_list->sizeHintForRow(m_list->count()-1);

        m_list->setFixedHeight(qMin(300, height));
        m_list->setFixedWidth(m_list->sizeHintForColumn(0)+5);
        m_list->move(ui->lineEdit->mapToGlobal(QPoint(ui->lineEdit->paddingLeft(), ui->lineEdit->height())));
        m_list->show();
    } else {
        m_list->hide();
    }
}
开发者ID:googl1,项目名称:MediaElch,代码行数:60,代码来源:FilterWidget.cpp

示例4: showConfigurations

void BearerEx::showConfigurations()
{
    listWidget->clear();
    QListWidgetItem* listItem;
    
    QNetworkConfiguration defaultConfig = m_NetworkConfigurationManager.defaultConfiguration();
    if (defaultConfig.type() == QNetworkConfiguration::UserChoice) {
        listItem = new QListWidgetItem();
        QFont font = listItem->font();
        font.setBold(true);
        font.setUnderline(true);
        listItem->setFont(font);        
        listItem->setText("       UserChoice");
        listItem->setData(Qt::UserRole, qVariantFromValue(defaultConfig));
        listWidget->addItem(listItem);
    }
    
    QList<QNetworkConfiguration> configurations = m_NetworkConfigurationManager.allConfigurations();
    for (int i=0; i<configurations.count(); i++)
    {
        listItem = new QListWidgetItem();
        QString text;
        if (configurations[i].type() == QNetworkConfiguration::InternetAccessPoint) {
            text.append("(IAP,");
        } else if (configurations[i].type() == QNetworkConfiguration::ServiceNetwork) {
            text.append("(SNAP,");
        }
        
        if ((configurations[i].state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
            text.append("Act) ");
        } else if ((configurations[i].state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
            text.append("Disc) ");
        } else {
            text.append("Def) ");
        }
        text.append(configurations[i].name());
        
        if (defaultConfig.isValid() && defaultConfig == configurations[i]) {
            QFont font = listItem->font();
            font.setBold(true);
            font.setUnderline(true);
            listItem->setFont(font);        
        }
        listItem->setText(text);
        listItem->setData(Qt::UserRole, qVariantFromValue(configurations[i]));
        listWidget->addItem(listItem);
    }
}
开发者ID:tsuibin,项目名称:emscripten-qt,代码行数:48,代码来源:bearerex.cpp

示例5: updateTable

void Tracker::updateTable(std::vector<item> * itemsToAdd, const int selectITEMS){

  for(unsigned i = 0; i < itemsToAdd->size(); i++){
    if((*itemsToAdd)[i].getDate().month == calendar->selectedDate().month() &&
       (*itemsToAdd)[i].getDate().day == calendar->selectedDate().day() &&
       (*itemsToAdd)[i].getDate().year == calendar->selectedDate().year()){

      QString nameToAdd = filingIn(QString::fromStdString((*itemsToAdd)[i].getName()), 17);
      QString cateToAdd = filingIn(QString::fromStdString((*itemsToAdd)[i].getLabel()), 14);
      QString amountToAdd = QString::number((*itemsToAdd)[i].getAmount());
      QString _itemToAdd;
      if(selectITEMS == 0){
        _itemToAdd = nameToAdd + cateToAdd + "-" + amountToAdd;
      }
      else{
        _itemToAdd = nameToAdd + cateToAdd + "+" + amountToAdd;
      }
      QListWidgetItem * itemToAdd = new QListWidgetItem;
      itemToAdd->setText(_itemToAdd);
      itemToAdd->setFont(QFont("Monaco", 10, QFont::Bold));
      //std::cout<<itemToAdd->text().toStdString().c_str()<<std::endl;
      detailList->addItem(itemToAdd);
    }
  }

}
开发者ID:ChangleLiang,项目名称:Expense-Tracker,代码行数:26,代码来源:mainwindow.cpp

示例6: 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

示例7: addSession

void MainWindow::addSession()
{
    if (!current_db_class) { return; }

    MTListWidget * lw = new MTListWidget;
    QDialog * d = createAddSessionDialogue(tr("Add session"), lw);
    QList<QDateTime> sessions_list;
    for (int i = 0; i < CLLSSListWidget->count(); ++i) {
        sessions_list << CLLSSListWidget->item(i)->data(Qt::UserRole).toDateTime();
    }
    QFont font; font.setBold(true);
    for (int i = 0; i < SVLSListWidget->count(); ++i) {
        if (sessions_list.contains(SVLSListWidget->item(i)->data(Qt::UserRole).toDateTime())) { continue; }
        QListWidgetItem * item = new QListWidgetItem(*(SVLSListWidget->item(i)));
        item->setFont(font);
        item->setBackground(QBrush(QColor(255, 255, 255)));
        item->setForeground(QBrush(QColor(0, 0, 0)));
        lw->addItem(item);
    }
    for (int i = 0; i < SVLASListWidget->count(); ++i) {
        if (sessions_list.contains(SVLASListWidget->item(i)->data(Qt::UserRole).toDateTime())) { continue; }
        QListWidgetItem * item = new QListWidgetItem(*(SVLASListWidget->item(i)));
        item->setBackground(QBrush(QColor(255, 255, 255)));
        item->setForeground(QBrush(QColor(0, 0, 0)));
        lw->addItem(item);
    }
    lw->setCurrentRow(0);
    if (!d->exec()) { delete d; return; }
    if (lw->currentItem() == NULL) { delete d; return; }
    QDateTime datetime = lw->currentItem()->data(Qt::UserRole).toDateTime();
    current_db_class->addSession(datetime);
    QListWidgetItem * item = new QListWidgetItem(*(lw->currentItem()));
    item->setFont(QFont());
    CLLSSListWidget->addItem(item);
    delete d;
    setDatabaseModified();
    Session * session = current_db_sessions.value(datetime, current_db_archivedsessions.value(datetime, new ArchivedSession(this)));
    SessionWizard wizard(session, current_db_class, this);
    wizard.setWindowModality(Qt::WindowModal);
    wizard.exec();
    for (int i = 0; i < wizard.numMatchedPairs(); ++i) {
        current_db_class->member(wizard.studentNumberInClass(i))->addSession(datetime, wizard.studentNumberInSession(i));
    }
    setCurrentClassMember(CLLSListWidget->highlightedItem());
    CLSCAverageLabel->setText(QString("%1%").arg(current_db_class->average(&current_db_sessions, &current_db_archivedsessions)));
}
开发者ID:nayanapriyankara,项目名称:itest,代码行数:46,代码来源:class_viewer.cpp

示例8: addGroup

void Radio::addGroup(const QString &groupName)
{
	QFont groupFont;
	groupFont.setBold(true);
	groupFont.setPointSize(groupFont.pointSize() + 2);

	QListWidgetItem *lWI = new QListWidgetItem("\n-- " + groupName + " --\n", lW);
	lWI->setData(Qt::TextAlignmentRole, Qt::AlignCenter);
	lWI->setIcon(QIcon(":/radio"));
	lWI->setFont(groupFont);
}
开发者ID:biddyweb,项目名称:QMPlay2,代码行数:11,代码来源:Radio.cpp

示例9: QDialog

/*!
    Constructs a VkOptionsDialog
*/
VkOptionsDialog::VkOptionsDialog( QWidget* parent )
   : QDialog( parent )
{
   // ------------------------------------------------------------
   // basic dialog setup
   setObjectName( QString::fromUtf8( "VkOptionsDialog" ) );
   setWindowTitle( "[*]Valkyrie Options Dialog" ); // [*] == 'windowModified' placeholder
   setupLayout();
   
   // ------------------------------------------------------------
   // Add categories, and the pages
   // Note: both the pages and categories list use the same 'index',
   // which is how we keep them in sync.
   // TODO: if any complaints re speed, load the pages on demand.
   VkObjectList objList = (( MainWindow* )parent )->getValkyrie()->vkObjList();
   
   for ( int i = 0; i < objList.size(); ++i ) {
   
      // Allow the VkObject to create the appropriate options page
      // Pass 'this' so constructor widgets auto-size correctly.
      VkObject* obj = objList.at( i );
      VkOptionsPage* page = obj->createVkOptionsPage();
      vk_assert( page != 0 );
      page->init();
      connect( page, SIGNAL( modified() ), this, SLOT( pageModified() ) );
      // handle e.g. user pressing return in an ledit
      connect( page, SIGNAL( apply() ), this, SLOT( apply() ) );
      
      // Set list item entry
      QListWidgetItem* item = new QListWidgetItem( contentsListWidget );
      QString itemName = obj->objectName();
      itemName[0] = itemName[0].toUpper();
      item->setText( itemName );

      QFont font = item->font();
      font.setBold( true );
      font.setPointSize( font.pointSize() * 1.2 );
      item->setFont( font );

      // insert into stack (takes ownership)
      optionPages->addWidget( page );
   }
   
   contentsListWidget->setCurrentRow( 0 );
   contentsListWidget->setFocus();
   optionPages->setCurrentIndex( 0 );
   
   // Give a max to our contentsList, based on hints from the list-items.
   // TODO: surely this can be done automatically?
   // - QSizePolicy::* don't seem to do the job :-(
   contentsListWidget->setMaximumWidth( 40 + contentsListWidget->sizeHintForColumn( 0 ) );
   
   ContextHelp::addHelp( this, urlValkyrie::optsDlg );
}
开发者ID:Grindland,项目名称:valkyrie,代码行数:57,代码来源:vk_options_dialog.cpp

示例10:

void
UIPlaylist::setBold(unsigned int row, bool b)
{
	QListWidgetItem* item = widgetPlaylist->item(row);
	if (item)
	{
		QFont tmp;
		tmp.setBold(b);		
		item->setFont(tmp);
	}
}
开发者ID:ThamimHayath,项目名称:mehdiaplayer,代码行数:11,代码来源:UIPlaylist.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: updateSyntaxFont

void ConfigDialog::updateSyntaxFont()
{
  QListWidgetItem *item = shListWidget->currentItem();
  QFont font;
  if(shBoldButton->isChecked())
    font.setWeight(QFont::Bold);
  if(shItalicButton->isChecked())
    font.setItalic(true);
  item->setFont(font);

  item->setForeground(shColorButton->currentColor());
}
开发者ID:thibault7249,项目名称:dbmaster,代码行数:12,代码来源:configdialog.cpp

示例13: symbol

GuiDelimiter::GuiDelimiter(GuiView & lv)
	: GuiDialog(lv, "mathdelimiter", qt_("Math Delimiter"))
{
	setupUi(this);

	connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));

	setFocusProxy(leftLW);

	leftLW->setViewMode(QListView::IconMode);
	rightLW->setViewMode(QListView::IconMode);

	leftLW->setDragDropMode(QAbstractItemView::NoDragDrop);
	rightLW->setDragDropMode(QAbstractItemView::NoDragDrop);

	initMathSymbols();

	typedef map<char_type, QListWidgetItem *> ListItems;
	ListItems list_items;
	// The last element is the empty one.
	int const end = nr_latex_delimiters - 1;
	for (int i = 0; i < end; ++i) {
		string const delim = latex_delimiters[i];
		MathSymbol const & ms =	mathSymbol(delim);
		QString symbol(ms.fontcode?
			QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
		QListWidgetItem * lwi = new QListWidgetItem(symbol);
		lwi->setToolTip(toqstr(delim));
		FontInfo lyxfont;
		lyxfont.setFamily(ms.fontfamily);
		lwi->setFont(frontend::getFont(lyxfont));
		list_items[ms.unicode] = lwi;
		leftLW->addItem(lwi);
	}

	for (int i = 0; i != leftLW->count(); ++i) {
		MathSymbol const & ms =	mathSymbol(
			fromqstr(leftLW->item(i)->toolTip()));
		rightLW->addItem(list_items[doMatch(ms.unicode)]->clone());
	}

	// The last element is the empty one.
	leftLW->addItem(qt_("(None)"));
	rightLW->addItem(qt_("(None)"));

	sizeCO->addItem(qt_("Variable"));

	for (int i = 0; *biggui[i]; ++i)
		sizeCO->addItem(qt_(biggui[i]));

	on_leftLW_currentRowChanged(0);
	bc().setPolicy(ButtonPolicy::IgnorantPolicy);
}
开发者ID:hashinisenaratne,项目名称:HSTML,代码行数:53,代码来源:GuiDelimiter.cpp

示例14: onlineStateChanged

void BearerEx::onlineStateChanged(bool isOnline)
{
    QListWidgetItem* listItem = new QListWidgetItem();
    QFont font = listItem->font();
    font.setBold(true);
    listItem->setFont(font);        
    if (isOnline) {
        listItem->setText(QString("> Online"));
    } else {
        listItem->setText(QString("< Offline"));
    }
    eventListWidget->addItem(listItem);
}
开发者ID:tsuibin,项目名称:emscripten-qt,代码行数:13,代码来源:bearerex.cpp

示例15: QListWidgetItem

QListWidgetItem *BlackBerryDeviceConfigurationWizardSetupPage::createDeviceListItem(
        const QString &displayName, ItemKind itemKind) const
{
    QListWidgetItem *item = new QListWidgetItem(displayName);
    if (itemKind == PleaseWait || itemKind == Note) {
        item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
        QFont font = item->font();
        font.setItalic(true);
        item->setFont(font);
    }
    item->setData(ItemKindRole, QVariant::fromValue(itemKind));
    return item;
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:13,代码来源:blackberrydeviceconfigurationwizardpages.cpp


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