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


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

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


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

示例1: insertLayer

void TupLayerIndex::insertLayer(int position, const QString &name)
{
    if (position >= 0 && position <= rowCount()) {

        QTableWidgetItem *newLayer = new QTableWidgetItem(name);
        newLayer->setFont(QFont("Arial", 8, QFont::Normal, false));
        newLayer->setTextAlignment(Qt::AlignCenter);

        newLayer->setBackgroundColor(palette().background().color());
        newLayer->setTextColor(palette().foreground().color());

        insertRow(position);

        setItem(position, 0, newLayer);
        fixSize();
    }
}
开发者ID:nanox,项目名称:tupi,代码行数:17,代码来源:tuplayerindex.cpp

示例2: FillTable

/**
 * @brief FillTable fill table
 */
void DialogHistory::FillTable()
{
    ui->tableWidget->clear();
    const QVector<VToolRecord> *history = doc->getHistory();
    SCASSERT(history != nullptr);
    qint32 currentRow = -1;
    qint32 count = 0;
    ui->tableWidget->setRowCount(history->size());
    for (qint32 i = 0; i< history->size(); ++i)
    {
        const VToolRecord tool = history->at(i);
        if (tool.getNameDraw() != doc->GetNameActivDraw())
        {
            continue;
        }
        const QString historyRecord = Record(tool);
        if (historyRecord.isEmpty() ==false)
        {
            currentRow++;

            {
                QTableWidgetItem *item = new QTableWidgetItem(QString());
                item->setTextAlignment(Qt::AlignHCenter);
                item->setData(Qt::UserRole, tool.getId());
                ui->tableWidget->setItem(currentRow, 0, item);
            }

            QTableWidgetItem *item = new QTableWidgetItem(historyRecord);
            item->setFont(QFont("Times", 12, QFont::Bold));
            item->setFlags(item->flags() ^ Qt::ItemIsEditable);
            ui->tableWidget->setItem(currentRow, 1, item);
            ++count;
        }
    }
    ui->tableWidget->setRowCount(count);
    if (history->size()>0)
    {
        cursorRow = currentRow;
        QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
        SCASSERT(item != nullptr);
        item->setIcon(QIcon("://icon/32x32/put_after.png"));
    }
    ui->tableWidget->resizeColumnsToContents();
    ui->tableWidget->resizeRowsToContents();
    ui->tableWidget->verticalHeader()->setDefaultSectionSize(20);
}
开发者ID:jessikbarret,项目名称:Valentina,代码行数:49,代码来源:dialoghistory.cpp

示例3: showFontDialog

void ConfigAppearanceWidget::showFontDialog()
{
	if (m_itemHighlighted < 0)
		return;

	bool ok;
	QFont currentFont;
	currentFont.fromString(m_itemFonts.at(m_itemHighlighted));
	const QFont newFont = FontDialog::getFont(&ok, currentFont, this);
	if (ok)
	{
		QTableWidgetItem *item = ui.itemTable->item(m_itemHighlighted, 0);
		m_itemFonts.replace(m_itemHighlighted, newFont.toString());
		item->setFont(newFont);
		setItemToolTip(item, newFont);
	}
}
开发者ID:KarateSnowMachine,项目名称:qtikz-svn,代码行数:17,代码来源:configappearancewidget.cpp

示例4: msg

/***************************************************************************
  Adds news message to mesg_table
***************************************************************************/
void messagewdg::msg(const struct message *pmsg)
{
  int i;
  QFont f;
  QTableWidgetItem *item;

  item = new QTableWidgetItem;
  item->setText(pmsg->descr);
  i = mesg_table->rowCount();
  mesg_table->insertRow(i);
  if (pmsg->visited) {
    f = item->font();
    f.setItalic(true);
    item->setFont(f);
  }
  mesg_table->setItem(i, 0, item);
  msg_update();
  mesg_table->scrollToBottom();
}
开发者ID:longturn,项目名称:freeciv-S2_5,代码行数:22,代码来源:messagewin.cpp

示例5: CreateColumns

int LDFCommonTableWidget::CreateColumns(QList<QString>& strColumnNames)
{
    clear();
    int nColumnClount =strColumnNames.size();
    setColumnCount(nColumnClount);
    setRowCount(0);
    int nColumn = 0;
    int nWidth = (width()-10)/strColumnNames.size();
for ( auto itr : strColumnNames )
    {
        QTableWidgetItem* pTablewidgetitem = new QTableWidgetItem();
        pTablewidgetitem->setText(strColumnNames.at(nColumn));
        pTablewidgetitem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter|Qt::AlignCenter);
        pTablewidgetitem->setFont(m_ldfFont);
        setColumnWidth(nColumn, nWidth);
        setHorizontalHeaderItem(nColumn++, pTablewidgetitem);
    }
    return 0;
}
开发者ID:ETAS-Nithin,项目名称:busmaster,代码行数:19,代码来源:LDFCommonTableWidget.cpp

示例6: append

/** Add a track to this Playlist instance. */
void Playlist::append(const MediaSource &m)
{
	// Resolve metaDatas from TagLib
	TagLib::FileRef f(m.fileName().toLocal8Bit().data());
	if (!f.isNull()) {
		sources.append(m);
		QString title(f.tag()->title().toCString());
		if (title.isEmpty()) {
			// Filename in a MediaSource doesn't handle cross-platform QDir::separator(), so '/' is hardcoded
			title = m.fileName().split('/').last();
		}

		// Then, construct a new row with correct informations
		QList<QTableWidgetItem *> widgetItems;
		QTableWidgetItem *trackItem = new QTableWidgetItem(QString::number(f.tag()->track()));
		QTableWidgetItem *titleItem = new QTableWidgetItem(title);
		QTableWidgetItem *albumItem = new QTableWidgetItem(f.tag()->album().toCString());
		QTableWidgetItem *lengthItem = new QTableWidgetItem(this->convertTrackLength(f.audioProperties()->length()));
		QTableWidgetItem *artistItem = new QTableWidgetItem(f.tag()->artist().toCString());
		QTableWidgetItem *ratingItem = new QTableWidgetItem("***");
		QTableWidgetItem *yearItem = new QTableWidgetItem(QString::number(f.tag()->year()));

		widgetItems << trackItem << titleItem << albumItem << lengthItem << artistItem << ratingItem << yearItem;

		int currentRow = rowCount();
		insertRow(currentRow);

		QFont font = Settings::getInstance()->font(Settings::PLAYLIST);
		for (int i=0; i < widgetItems.length(); i++) {
			QTableWidgetItem *item = widgetItems.at(i);
			item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
			item->setFont(font);
			setItem(currentRow, i, item);
			QFontMetrics fm(font);
			setRowHeight(currentRow, fm.height());
		}

		trackItem->setTextAlignment(Qt::AlignCenter);
		lengthItem->setTextAlignment(Qt::AlignCenter);
		ratingItem->setTextAlignment(Qt::AlignCenter);
		yearItem->setTextAlignment(Qt::AlignCenter);
	}
}
开发者ID:GothCodeMonkey,项目名称:Madame-Miam-Miam-Music-Player,代码行数:44,代码来源:playlist.cpp

示例7: addNewRow

void TargetList::addNewRow(QString fileName, QString name, QString coordinates, QString description)
{
    // Creates image preview item
    QTableWidgetItem *image = new QTableWidgetItem();
    QBrush brush;
    QImage brushImage;
    if (fileName == "")
        brushImage.load(defaultImagePath);
    else
        brushImage.load(fileName);
    // Resize image -> Make this dependent on row/col size
    int width = 150;
    int height = 100;
    QImage scaledBrushImage = brushImage.scaled(width, height, Qt::KeepAspectRatio);

    image->setData(Qt::DecorationRole, QPixmap(fileName).scaled(150, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    image->setTextAlignment(Qt::AlignHCenter);

    // Apply resized image
    brush.setTextureImage(scaledBrushImage);
    //image->setImage(brush);

    // Creates name item
    QFont font("Segoe UI", 11, QFont::Bold);
    QTableWidgetItem *nameItem = new QTableWidgetItem();
    nameItem->setText(name);
    nameItem->setFont(font);

    // Creates coordinate item
    QTableWidgetItem *coordItem = new QTableWidgetItem();
    coordItem->setText(coordinates);

    // Creates description item
    QTableWidgetItem *descItem = new QTableWidgetItem();
    descItem->setText(description);

    // Places item in a TargetListItem and adds it to the target list
    TargetListItem *newItem = new TargetListItem(image, nameItem, coordItem, descItem);
    newItem->imageFilePath = fileName;
    rows->prepend(newItem);

    refreshTable();
}
开发者ID:jG0D,项目名称:groundstation,代码行数:43,代码来源:targetlist.cpp

示例8: setHHeaderText

void ViewTable::setHHeaderText(const QStringList &list )
{
	if( list.count() < columnCount() )
		return;

	QTableWidgetItem *cell;
	for(int i = 0; i < columnCount(); i++)
	{
		cell = horizontalHeaderItem(i);
		if( cell )
		{
			QFont font = cell->font();
			font.setBold( true );
			cell->setFont( font );

			cell->setText( list[i] );
		}
	}
}
开发者ID:petrpopov,项目名称:db_transactions,代码行数:19,代码来源:viewtable.cpp

示例9: fnt

void
TagColorEditor::setColors()
{
  QFont fnt("Helvetica", 10);

  uchar *colors = Global::tagColors();
  for (int i=0; i < 256; i++)
    {      
      int r,g,b;
      float a;

      r = colors[4*i+0];
      g = colors[4*i+1];
      b = colors[4*i+2];

      QTableWidgetItem *colorItem = new QTableWidgetItem;
      colorItem->setFont(fnt);
      colorItem->setData(Qt::DisplayRole, QString("%1").arg(i));
      if (colors[4*i+3] > 250)
	colorItem->setCheckState(Qt::Checked);
      else
	colorItem->setCheckState(Qt::Unchecked);
      colorItem->setBackground(QColor(r,g,b));
      
      //int row = i/8;
      //int col = i%8; 
      int row, col;
      if (i == 0)
	{
	  row = 0;
	  col = 0;
	}
      else
	{
	  row = 1 + (i-1)/5;
	  col = (i-1)%5;
	}
     table->setItem(row, col, colorItem);
    }
}
开发者ID:drancom,项目名称:drishti,代码行数:40,代码来源:tagcoloreditor.cpp

示例10: addNewRow

void TargetList::addNewRow(QString fileName, QString name, QString coordinates, QString description, int x, int y, bool refresh)
{
    // Creates image preview item
    QTableWidgetItem *image = new QTableWidgetItem();
    QBrush brush;
    QImage brushImage;
    if (fileName == "")
        brushImage.load(defaultImagePath);
    else
        brushImage.load(fileName);
    // Resize image
    int width = 100;
    int height = 100;
    QImage scaledBrushImage = brushImage.scaled(width, height, Qt::IgnoreAspectRatio);
    // Apply resized image
    brush.setTextureImage(scaledBrushImage);
    image->setBackground(brush);

    // Creates name item
    QFont font("Segoe UI", 11, QFont::Bold);
    QTableWidgetItem *nameItem = new QTableWidgetItem();
    nameItem->setText(name);
    nameItem->setFont(font);

    // Creates coordinate item
    QTableWidgetItem *coordItem = new QTableWidgetItem();
    coordItem->setText(coordinates);

    // Creates description item
    QTableWidgetItem *descItem = new QTableWidgetItem();
    descItem->setText(description);

    // Places item in a TargetListItem and adds it to the target list
    TargetListItem *newItem = new TargetListItem(image, nameItem, coordItem, descItem, x, y);
    newItem->imageFilePath = fileName;
    rows->append(newItem);

    if (refresh)
        refreshTable();
}
开发者ID:JustCourt,项目名称:cv16-interface,代码行数:40,代码来源:targetlist.cpp

示例11: font

void tst_QItemDelegate::font()
{
    Q_CHECK_PAINTEVENTS

    QFETCH(QString, itemText);
    QFETCH(QString, properties);
    QFETCH(QFont, itemFont);
    QFETCH(QFont, viewFont);

    QTableWidget table(1, 1);
    table.setFont(viewFont);

    TestItemDelegate *delegate = new TestItemDelegate(&table);
    table.setItemDelegate(delegate);
    table.show();
#ifdef Q_WS_X11
    qt_x11_wait_for_window_manager(&table);
#endif

    QTableWidgetItem *item = new QTableWidgetItem;
    item->setText(itemText);
    item->setFont(itemFont);
    table.setItem(0, 0, item);

    QApplication::processEvents();
#ifdef Q_WS_QWS
    QApplication::sendPostedEvents(); //glib workaround
#endif

    QTRY_COMPARE(delegate->displayText, item->text());
    if (properties.contains("italic")) {
        QCOMPARE(delegate->displayFont.italic(), item->font().italic());
    }
    if (properties.contains("bold")) {
        QCOMPARE(delegate->displayFont.bold(), item->font().bold());
    }
    if (properties.contains("family")) {
        QCOMPARE(delegate->displayFont.family(), item->font().family());
    }
}
开发者ID:redanium,项目名称:qt,代码行数:40,代码来源:tst_qitemdelegate.cpp

示例12: updateRowInTable

void tablewidget::updateRowInTable( QTableWidget * table,const QStringList& list,int row,const QFont& font )
{
	QTableWidgetItem * item ;

	int j = list.size() ;

	if( j != table->columnCount() ){
		qDebug() << "ERROR: table column count is NOT the same as QStringList size ";
		return ;
	}

	if( row < table->rowCount() ){
		for( int i = 0 ; i < j ; i++ ){
			item = table->item( row,i ) ;
			item->setText( list.at( i ) ) ;
			item->setTextAlignment( Qt::AlignCenter ) ;
			item->setFont( font ) ;
		}

		table->setCurrentCell( row,j - 1 ) ;
	}
}
开发者ID:bankonme,项目名称:zuluCrypt,代码行数:22,代码来源:tablewidget.cpp

示例13: slot_TableRowEnter

//鼠标滑动到每一行
void MusicList::slot_TableRowEnter( int row, int /*col*/ )
{
	QTableWidgetItem *item = NULL;

	//还原上一行的颜色
	item = this->item(m_nPerviousColorRow, 0);
	
	if (item != NULL)
	{
		//this->setRowColor(m_nPerviousColorRow, QColor(0, 0, 0, 0));
		for (int i = 0; i < this->columnCount(); ++i)
		{
			QTableWidgetItem *item = this->item(m_nPerviousColorRow, i);
			item->setFont(QFont("微软雅黑", 10, QFont::Normal));
			item->setBackgroundColor(QColor(0, 0, 0, 0));
		}
	}

	//设置当前行颜色
	this->setRowColor(row, QColor(5, 184, 204));

	m_nPerviousColorRow = row;
}
开发者ID:keygen8-git,项目名称:CZPlayer2.0,代码行数:24,代码来源:musiclist.cpp

示例14: addPurchases

/*Add to owned games*/
void Functions::addPurchases(QTableWidget *purchased, int &row, int &col, QString title, QString coverArt, QLabel *Error){

    QPushButton *button =new QPushButton;
    QTableWidgetItem *gameTitle = new QTableWidgetItem;
    QVBoxLayout *layout = new QVBoxLayout;
    QWidget* wdg = new QWidget;
    QLabel *label = new QLabel;
    QPixmap pixm (":/Assets/Activities/" +coverArt);

    title = " " + title;

    button->setStyleSheet("QPushButton {"
                                  "background-color: #336699;"
                                  "border-style: solid;"
                                  "border-width: 2px;"
                                  "border-color: #204060;"
                                  "font: 12px;"
                                  "color: white;"
                                  "padding-top:8px;"
                                  "padding-bottom:8px;"
                                  "padding-left: 8px;"
                                  "padding-right: 8px;}"
                          "QPushButton:hover {"
                            "border: 2px solid #26b7ff;"
                            "}"
                          "QPushButton:pressed {"
                            "color:white;"
                            "background-color:#204060;"
                            "}"
                          );

    button->setMaximumHeight(35);
    button->setMaximumWidth(135);
    button->setFocusPolicy(Qt::NoFocus);
    button->setText("Download");

    layout->addSpacing(6);
    layout->addWidget(button);
    layout->addSpacing(6);

    //Determine Color of Rows
    if ( row % 2 == 0 ){
       wdg->setStyleSheet("background-color: #34495e");
    }else {
      wdg->setStyleSheet("background-color: #2c3e50");
    }

    wdg->setLayout(layout);
    purchased->setRowCount(row + 1);
    purchased->setRowHeight(row,69);
    purchased->setColumnWidth(0,169);
    purchased->setColumnWidth(1,135);
    purchased->setRowHeight(2,69);
    purchased->setColumnWidth(2,173);
    purchased->setCellWidget(row,0,label);
    purchased->setColumnWidth(1,300);
    purchased->setItem(row, 1,gameTitle);
    purchased->setCellWidget(row, 2,wdg);

    label->setPixmap(pixm.scaled(169,69,Qt::KeepAspectRatio));

    gameTitle->setTextColor("#26b7ff");
    gameTitle->setFont(QFont( "Arial", 18, QFont::Bold));
    gameTitle->setText(title);

    Error->setEnabled(false);
    Error->setVisible(false);

    row +=1;
    col +=1;

}
开发者ID:ryan-kellert,项目名称:Videogame-Store,代码行数:73,代码来源:functions.cpp

示例15: cancel

/*!
	\brief Reset the subcontrols to reflect the data of the format scheme being edited

	The name can be a bit misleading at first, it has been chosen
	because it directly maps to the effect a "cancel" button would
	have on the widget
*/
void QFormatConfig::cancel()
{
	m_table->clearContents();

	QTime T; T.start();
	QFontDatabase database;
	QStringList fonts = database.families();
	fonts.insert(0, tr("<default>"));
	
	if ( m_currentScheme )
	{
		if (m_categories.isEmpty()) {
			QList<QString> &temp=addCategory("");
			for ( int i = 0; i < m_currentScheme->formatCount(); i++ )
				temp.append(m_currentScheme->id(i));
		}


		int n = 0;
		foreach ( const QList<QString> c, m_categories)
			n+=c.size();
		n+=m_categories.size()-1;
		m_table->setRowCount(n);

		int r = 0;
		for ( int c = 0; c < m_categories.size(); c++ ) {
			if (c!=0) {
				m_table->setItem(r, 0, new QTableWidgetItem());
				m_table->setSpan(r++, 0, 1, 13);
			}
			QTableWidgetItem *item = new QTableWidgetItem(m_categories[c][0]);
			QFont f = item->font(); f.setBold(true); item->setFont(f); item->setBackground(QApplication::palette().mid());
			m_table->setItem(r, 0, item);
			m_table->setSpan(r++, 0, 1, 13);

			for ( int f = 1; f < m_categories[c].size(); f++ ) {
				QString fid = m_categories[c][f];
				const QFormat& fmt = m_currentScheme->format(fid);

				QTableWidgetItem *item;

				item = new QTableWidgetItem(tr(qPrintable(fid)));
				item->setData(Qt::UserRole, fid);
				item->setFlags(Qt::ItemIsEnabled);
				m_table->setItem(r, 0, item);

				item = new QTableWidgetItem;
				item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
				item->setCheckState(fmt.weight == QFont::Bold ? Qt::Checked : Qt::Unchecked);
				item->setToolTip(m_table->horizontalHeaderItem(1)->toolTip());
				m_table->setItem(r, 1, item);

				item = new QTableWidgetItem;
				item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
				item->setCheckState(fmt.italic ? Qt::Checked : Qt::Unchecked);
				item->setToolTip(m_table->horizontalHeaderItem(2)->toolTip());
				m_table->setItem(r, 2, item);

				item = new QTableWidgetItem;
				item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
				item->setCheckState(fmt.underline ? Qt::Checked : Qt::Unchecked);
				item->setToolTip(m_table->horizontalHeaderItem(3)->toolTip());
				m_table->setItem(r, 3, item);

				item = new QTableWidgetItem;
				item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
				item->setCheckState(fmt.overline ? Qt::Checked : Qt::Unchecked);
				item->setToolTip(m_table->horizontalHeaderItem(4)->toolTip());
				m_table->setItem(r, 4, item);

				item = new QTableWidgetItem;
				item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
				item->setCheckState(fmt.strikeout ? Qt::Checked : Qt::Unchecked);
				item->setToolTip(m_table->horizontalHeaderItem(5)->toolTip());
				m_table->setItem(r, 5, item);

				item = new QTableWidgetItem;
				item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
				item->setCheckState(fmt.waveUnderline ? Qt::Checked : Qt::Unchecked);
				item->setToolTip(m_table->horizontalHeaderItem(6)->toolTip());
				m_table->setItem(r, 6, item);

				m_table->setCellWidget(r, 7, new QSimpleColorPicker(fmt.foreground));
				m_table->cellWidget(r, 7)->setToolTip(m_table->horizontalHeaderItem(7)->toolTip());
				//m_table->cellWidget(i, 7)->setMaximumSize(22, 22);

				m_table->setCellWidget(r, 8, new QSimpleColorPicker(fmt.background));
				m_table->cellWidget(r, 8)->setToolTip(m_table->horizontalHeaderItem(8)->toolTip());
				//m_table->cellWidget(i, 8)->setMaximumSize(22, 22);

				m_table->setCellWidget(r, 9, new QSimpleColorPicker(fmt.linescolor));
				m_table->cellWidget(r, 9)->setToolTip(m_table->horizontalHeaderItem(9)->toolTip());
				//m_table->cellWidget(i, 9)->setMaximumSize(22, 22);
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:texstudio,代码行数:101,代码来源:qformatconfig.cpp


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