本文整理汇总了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();
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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;
}
示例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);
}
}
示例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();
}
示例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] );
}
}
}
示例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);
}
}
示例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();
}
示例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());
}
}
示例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 ) ;
}
}
示例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;
}
示例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;
}
示例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);
//.........这里部分代码省略.........