本文整理汇总了C++中QTableWidgetItem::font方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidgetItem::font方法的具体用法?C++ QTableWidgetItem::font怎么用?C++ QTableWidgetItem::font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem::font方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
QVERIFY(QTest::qWaitForWindowExposed(&table));
QTableWidgetItem *item = new QTableWidgetItem;
item->setText(itemText);
item->setFont(itemFont);
table.setItem(0, 0, item);
QApplication::processEvents();
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());
}
}
示例2: slotListCamerasReady
void MainWindow::slotListCamerasReady()
{
m_chdkptp->m_cameras = m_listCamerasWatcher.future().result();
m_ui->camerasTableWidget->clearContents();
m_ui->camerasTableWidget->clearSpans();
int count = m_chdkptp->m_cameras.size();
m_ui->camerasTableWidget->setRowCount(count);
for (int i = 0; i < count; ++i) {
Camera cam = m_chdkptp->m_cameras.at(i);
m_ui->camerasTableWidget->setItem(i, 0, new QTableWidgetItem(QString("%1").arg(i)));
m_ui->camerasTableWidget->setItem(i, 1, new QTableWidgetItem(QString("%1/%2").arg(cam.bus()).arg(cam.dev())));
// m_ui->camerasTableWidget->setItem(i, 2, new QTableWidgetItem(cam.serialNumber));
}
if (m_chdkptp->m_cameras.size() == 0) {
// http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?index=201&key=QTableWidgetMergeCells
m_ui->camerasTableWidget->setRowCount(1);
QTableWidgetItem* item = new QTableWidgetItem("No cameras connected");
item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
QFont font = item->font();
font.setItalic(true);
item->setFont(font);
m_ui->camerasTableWidget->setItem(0, 0, item);
m_ui->camerasTableWidget->setSpan(0, 0, 1, 3);
}
for (int i = 0; i < count; ++i) {
// This does not work if we run connect() before ".startSerialNumberQuery()", why?
m_chdkptp->m_cameras[i].startSerialNumberQuery();
connect(&m_chdkptp->m_cameras.at(i), SIGNAL(serialNumberReady(QString)), this, SLOT(serialNumberReady(QString)));
}
}
示例3: setBookmarkToRow
void EditBookmarksDialog::setBookmarkToRow(int ARow, const IBookmark &ABookmark)
{
QTableWidgetItem *nameItem = new QTableWidgetItem;
nameItem->setText(ABookmark.name);
if (ABookmark.type==IBookmark::TypeRoom && ABookmark.room.autojoin)
{
QFont font = nameItem->font();
font.setBold(true);
nameItem->setFont(font);
}
nameItem->setData(TDR_TYPE,ABookmark.type);
nameItem->setData(TDR_NAME,ABookmark.name);
nameItem->setData(TDR_ROOMJID,ABookmark.room.roomJid.bare());
nameItem->setData(TDR_AUTO,ABookmark.room.autojoin);
nameItem->setData(TDR_NICK,ABookmark.room.nick);
nameItem->setData(TDR_PASSWORD,ABookmark.room.password);
nameItem->setData(TDR_URL,ABookmark.url.url.toString());
ui.tbwBookmarks->setItem(ARow,COL_NAME,nameItem);
QTableWidgetItem *valueItem = new QTableWidgetItem;
valueItem->setText(ABookmark.type==IBookmark::TypeUrl ? ABookmark.url.url.toString() : ABookmark.room.roomJid.uBare());
ui.tbwBookmarks->setItem(nameItem->row(),COL_VALUE,valueItem);
QTableWidgetItem *nickItem = new QTableWidgetItem;
nickItem->setText(ABookmark.room.nick);
ui.tbwBookmarks->setItem(nameItem->row(),COL_NICK,nickItem);
QTableWidgetItem *sortItem = new QTableWidgetItem;
sortItem->setText(nameItem->text());
ui.tbwBookmarks->setItem(nameItem->row(),COL_SORT,sortItem);
}
示例4: item_selected
/***************************************************************************
Slot executed when selection on meg_table has changed
***************************************************************************/
void messagewdg::item_selected(const QItemSelection &sl,
const QItemSelection &ds)
{
const struct message *pmsg;
int i;
QFont f;
QModelIndex index;
QModelIndexList indexes = sl.indexes();
QTableWidgetItem *item;
if (indexes.isEmpty()) {
return;
}
index = indexes.at(0);
i = index.row();
pmsg = meswin_get_message(i);
if (i > -1 && pmsg != NULL) {
if (QApplication::mouseButtons() == Qt::LeftButton
|| QApplication::mouseButtons() == Qt::RightButton) {
meswin_set_visited_state(i, true);
item = mesg_table->item(i, 0);
f = item->font();
f.setItalic(true);
item->setFont(f);
}
if (QApplication::mouseButtons() == Qt::LeftButton && pmsg->location_ok) {
meswin_goto(i);
}
if (QApplication::mouseButtons() == Qt::RightButton && pmsg->city_ok) {
meswin_popup_city(i);
}
}
mesg_table->clearSelection();
}
示例5: font
int TableWidgetItem::font ( lua_State * L )// const QFont
{
QTableWidgetItem* lhs = ValueInstaller2<QTableWidgetItem>::check( L, 1 );
QFont* res = ValueInstaller2<QFont>::create( L );
*res = lhs->font();
return 1;
}
示例6: showFitPage
void FitDialog::showFitPage()
{
int param_table_rows = boxParams->rowCount();
QString par = boxParam->text().simplified();
QStringList paramList = par.split(QRegExp("[,;]+[\\s]*"), QString::SkipEmptyParts);
int parameters = paramList.count();
boxParams->setRowCount(parameters);
boxParams->hideColumn(2);
if (parameters > 7)
parameters = 7;
boxParams->setMinimumHeight(4+(parameters+1)*boxParams->horizontalHeader()->height());
for (int i = param_table_rows; i<paramList.count(); i++)
{
QTableWidgetItem *it = new QTableWidgetItem(paramList[i]);
it->setFlags(!Qt::ItemIsEditable);
it->setBackground(QBrush(Qt::lightGray));
it->setForeground(QBrush(Qt::darkRed));
QFont font = it->font();
font.setBold(true);
it->setFont(font);
boxParams->setItem(i, 0, it);
it = new QTableWidgetItem(QLocale().toString(1.0, 'f', boxPrecision->value()));
it->setTextAlignment(Qt::AlignRight);
boxParams->setItem(i, 1, it);
}
for (int i = 0; i<paramList.count(); i++)
boxParams->item (i, 0)->setText(paramList[i]);
// FIXME: this check is pretty ugly, should be changed to a more elegant way some time
if (!boxUseBuiltIn->isChecked() ||
(boxUseBuiltIn->isChecked()&& categoryBox->currentRow()!=3 && categoryBox->currentRow()!=1))
{
boxParams->showColumn(2);
for (int i = 0; i<boxParams->rowCount(); i++ )
{
QTableWidgetItem *it = new QTableWidgetItem();
it->setFlags(!Qt::ItemIsEditable);
it->setBackground(QBrush(Qt::lightGray));
boxParams->setItem(i, 2, it);
QCheckBox *cb = new QCheckBox();
boxParams->setCellWidget(i, 2, cb);
}
}
boxFunction->setText(editBox->text().simplified());
lblFunction->setText(boxName->text() +" (x, " + par + ")");
tw->setCurrentWidget (fitPage);
}
示例7: 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());
}
}
示例8: CreateNewRow
void FieldEditPanel::CreateNewRow(int row)
{
QTableWidgetItem *item = new QTableWidgetItem(QIcon::fromTheme("list-add"), "", FieldValueNewType);
item->setToolTip("New?");
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
m_value_table->setItem(row, FieldValueIconColumn, item);
item = new QTableWidgetItem("New value...");
QFont font = item->font();
font.setItalic(true);
item->setFont(font);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
m_value_table->setItem(row, FieldValueNameColumn, item);
}
示例9: CreateNewAddrRow
void RegEditPanel::CreateNewAddrRow(int row)
{
QTableWidgetItem *item = new QTableWidgetItem(QIcon::fromTheme("list-add"), "", RegInstNewType);
item->setToolTip("New?");
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
m_instances_table->setItem(row, RegInstIconColumn, item);
item = new QTableWidgetItem("New instance...");
QFont font = item->font();
font.setItalic(true);
item->setFont(font);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
m_instances_table->setItem(row, RegInstNameColumn, item);
item = new QTableWidgetItem("");
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
m_instances_table->setItem(row, RegInstAddrColumn, item);
}
示例10: 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] );
}
}
}
示例11: 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();
}
示例12: if
virtual void HandleResponse(const QVariantMap& Response)
{
if(m_pView)
{
m_pView->m_bLockDown = true;
QStringList Info;
if(Response.contains("Error"))
Info.append(tr("Error: %2").arg(Response["Error"].toString()));
if(theGUI->Cfg()->GetInt("Gui/AdvancedControls") == 1)
Info.append(tr("FileID: %1").arg(Response["ID"].toULongLong()));
m_pView->m_pInfo->setText(Info.join(", "));
m_pView->m_pFileName->setText(Response["FileName"].toString());
QVariantList HashMap = Response["HashMap"].toList();
m_pView->m_pHashes->setColumnCount(1);
#if QT_VERSION < 0x050000
m_pView->m_pHashes->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
#else
m_pView->m_pHashes->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
#endif
m_pView->m_pHashes->setRowCount(HashMap.count());
QStringList Hashes;
StrPair MasterHash = Split2(Response["MasterHash"].toString(), ":");
foreach(const QVariant& vHash, HashMap)
{
QVariantMap Hash = vHash.toMap();
QTableWidgetItem* pItem = new QTableWidgetItem(Hash["Value"].toString());
QFont Font = pItem->font();
if(Hash["Value"].toString() == MasterHash.second)
{
Font.setBold(true);
pItem->setData(Qt::UserRole, "Master");
}
else
pItem->setData(Qt::UserRole, Hash["State"]);
if(!MasterHash.first.isEmpty()) // file complate all hashes just black
{
if(Hash["State"] == "Parent")
Font.setItalic(true);
else if(Hash["State"] == "Empty")
pItem->setForeground(Qt::gray);
else if(Hash["State"] == "Aux")
pItem->setForeground(Qt::darkYellow);
else if(Hash["State"] == "Bad")
pItem->setForeground(Qt::darkRed);
else if(Hash["Value"].toString() != MasterHash.second)
pItem->setForeground(Qt::darkGreen);
}
pItem->setFont(Font);
m_pView->m_pHashes->setItem(Hashes.count(), 0, pItem);
m_pView->m_pHashes->resizeRowToContents(Hashes.count());
Hashes.append(Hash["Type"].toString());
}
m_pView->m_pHashes->setVerticalHeaderLabels(Hashes);
if(int Count = m_pView->m_pHashes->rowCount())
m_pView->m_pHashes->setMaximumHeight(((m_pView->m_pHashes->rowHeight(0)) * Count) + 2);
else
m_pView->m_pHashes->setMaximumHeight(30);
m_pView->m_IsComplete = Response["FileStatus"] == "Complete";
QVariantMap Properties = Response["Properties"].toMap();
m_pView->m_pRating->setCurrentIndex(Properties["Rating"].toInt());
m_pView->m_pDescription->setPlainText(Properties["Description"].toString());
m_pView->m_pCoverView->ShowCover(m_pView->m_ID, Properties["CoverUrl"].toString());
m_pView->m_pSubmit->setEnabled(false);
bool Searching = Response["FileJobs"].toStringList().contains("Searching");
if(m_pView->m_Mode == CFileListView::eFilesSearch || m_pView->m_Mode == CFileListView::eFilesGrabber)
{
if(!Searching && Properties["Description"].toString().isEmpty())
{
Searching = true;
CSetRatingJob* pSetRatingJob = new CSetRatingJob(m_pView->m_ID);
theGUI->ScheduleJob(pSetRatingJob);
}
if(Searching)
QTimer::singleShot(1000, m_pView, SLOT(UpdateDetails()));
}
m_pView->m_bLockDown = false;
}
示例13: 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);
//.........这里部分代码省略.........