本文整理汇总了C++中QToolButton::setFont方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::setFont方法的具体用法?C++ QToolButton::setFont怎么用?C++ QToolButton::setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolButton
的用法示例。
在下文中一共展示了QToolButton::setFont方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
// QPushButton *quit = new QPushButton(tr("Quit"));
QToolButton *quit = new QToolButton();
quit->setText(tr("Quit"));
quit->setFont(QFont("Times", 18, QFont::Bold));
quit->setMinimumSize(150, 50);
QLCDNumber *lcd = new QLCDNumber(2);
lcd->setSegmentStyle(QLCDNumber::Filled);
lcd->setMinimumSize(150, 150);
QSlider *slider = new QSlider(Qt::Horizontal);
slider->setRange(0, 99);
slider->setValue(0);
connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
connect(slider, SIGNAL(valueChanged(int)),
lcd, SLOT(display(int)));
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(lcd);
layout->addWidget(slider);
layout->addWidget(quit);
setLayout(layout);
}
示例2: foreach
foreach (QAction* action, actions) {
QToolButton* button = new QToolButton;
QFont font = button->font();
font.setPixelSize(14);
button->setFont(font);
button->setText(action->text());
d->m_flow_layout->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), action, SLOT(trigger()));
}
示例3: assignColorFromSMVTreeWidget
void FeatureTreeWidget::assignColorFromSMVTreeWidget(QString featureName)
{
QTreeWidgetItem *item = getItemFromFeatureName(featureName);
if (item!=0)
{
if (item->childCount()==0){
mainWindow->questionDialog->writeToLog("assignColor<1>");
Feature *f = getCorrespondingFeature(featureName);
Color *c = static_cast<MyListWidgetItem*>(listWidget->selectedItems().at(0))->getBGColor();
if (item->backgroundColor(0).isValid())
mainWindow->removeColorAssignment(static_cast<MyTreeWidgetItem*>(item));
colorManager->setColorForFeature(f,c);
//X zum Abwählen der Farbe setzen
if (itemWidget(item, 1))
itemWidget(item, 1)->show();
else{
QToolButton *deleteButton = new QToolButton(this);
deleteButton->setFont(QFont(QString("MS Shell Dlg 2"),9,10,false));
//deleteButton->setFixedSize(15,18);
deleteButton->setFixedWidth(16);
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/cross.png")),QIcon::Normal,QIcon::On);
deleteButton->setIcon(icon);
deleteButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setItemWidget(item,1,deleteButton);
connect(deleteButton,SIGNAL(clicked()),this,SLOT(removeColorAssignment()));
}
//aktualisiere SmvTreeWidget und TextEdit
mainWindow->updateSMVTreeTexture(f);
redrawListWidget();
//wenn Farbe schon in FeatureTreeWidget vorhanden, setze diese auf weiß/transparent
QList <QTreeWidgetItem*> *treeList = new QList <QTreeWidgetItem*>();
findBackGroundColor(c->color,root,treeList);
if (treeList->isEmpty()==false)
{
for (int i = 0;i < treeList->size();i++){
static_cast<MyTreeWidgetItem*>(treeList->at(i))->setBackgroundInvalid();
// treeList->at(i)->background(0).setStyle(Qt::NoBrush);
// treeList->at(i)->setBackgroundColor(0,QColor(0,0,0,0));
colorManager->deleteColorForFeature(getCorrespondingFeature(treeList->at(i)->text(0)));
}
}
//setze Farbe im FeatureTreeWidget
static_cast<MyTreeWidgetItem*>(item)->setBGColor(c);
//item->setBackgroundColor(0,selected->color);
}
}
}
示例4: createItems
void ItemsWidget::createItems(int categoryId)
{
// Remove pervious buttons from grid layout
this->removeItems();
// Get all items
QList<Model::Item> items = Services::Item::getByCategoryId(categoryId);
int i=0, col = 0, row = 1;
for(QList<Model::Item>::iterator p = items.begin(); p != items.end(); ++p ) {
QToolButton* button = new QToolButton;
button->setObjectName(QString("%1_itemButton").arg(p->id()));
button->setText((Settings::Language::getCurrentLanguage() == Settings::Language::Arabic) ? p->arabicName() : p->englishName());
if ( Settings::Language::getCurrentLanguage() == Settings::Language::English ) {
if ( p->id() == 2 || p->id() == 29)
button->setFont(QFont("Hacen Liner Screen Bd", 10, QFont::Normal));
else
button->setFont(QFont("Hacen Liner Screen Bd", 13, QFont::Normal));
}
else
button->setFont(QFont("Hacen Liner Screen Bd", 13, QFont::Normal));
button->setIconSize(QSize(128,128));
//button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
button->setToolTip(button->text());
button->setStatusTip(button->text());
connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
this->signalMapper->setMapping(button, p->id());
layout->addWidget(button, row, col);
col++;
i++;
if ( col % ButtonsPerLine == 0) {
row++;
col = 0;
}
}
}
示例5: constructUI
void FindWidget::constructUI()
{
QHBoxLayout* layout = new QHBoxLayout();// QBoxLayout::LeftToRight );
layout->setMargin(7);
setLayout( layout );
QToolButton* toggleButton = new QToolButton(this);
toggleButton->setFont( edbeeApp()->iconFont() );
toggleButton->setText( QChar(icon_repeat) );
toggleButton->setToolTip(tr("Wrap Around"));
toggleButton->setCheckable(true);
layout->addWidget( toggleButton, 0 );
toggleButton = new QToolButton(this);
toggleButton->setFont( edbeeApp()->iconFont() );
toggleButton->setText( QChar(icon_asterisk) );
toggleButton->setToolTip(tr("Regular Expressions"));
toggleButton->setCheckable(true);
layout->addWidget( toggleButton, 0 );
toggleButton = new QToolButton(this);
toggleButton->setFont( edbeeApp()->iconFont() );
toggleButton->setText( QChar(icon_font) );
toggleButton->setToolTip(tr("Case Sensitive"));
toggleButton->setCheckable(true);
layout->addWidget( toggleButton, 0 );
QLabel* label = new QLabel( tr("Find") );
layout->addWidget( label, 0, Qt::AlignLeft );
lineEditRef_ = new QLineEdit(this);
// lineEditRef_->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred);
// lineEditRef_->setSizePolicy( QSizePolicy::M);
// lineEditRef_->setMaximumWidth( 10000 );
layout->addWidget( lineEditRef_, 1);//, Qt::AlignLeft);
// layout->insertStretch(1);
// add the action
QToolButton* but = new QToolButton( this );
but->setFont( edbeeApp()->iconFont() );
but->setText( QChar(icon_caret_left) ); //<
but->setShortcut( editorRef_->controller()->keyMap()->getSequence("find_prev_match") );
but->setToolTip( QString(tr("Find Previous (%1)")).arg(but->shortcut().toString()) );
connect( but, SIGNAL(clicked()), SLOT(findPrevWord()) );
layout->addWidget( but, 0 );
but = new QToolButton( this );
but->setFont( edbeeApp()->iconFont() );
but->setText( QChar(icon_caret_right) ); // >
but->setShortcut( editorRef_->controller()->keyMap()->getSequence("find_next_match") );
but->setToolTip( QString(tr("Find Next (%1)")).arg(but->shortcut().toString()) );
connect( but, SIGNAL(clicked()), SLOT(findNextWord()) );
layout->addWidget( but, 0 );
but = new QToolButton( this );
but->setFont( edbeeApp()->iconFont() );
but->setText( QChar(icon_th) ); // >
but->setShortcut( editorRef_->controller()->keyMap()->getSequence("sel_all_matches") );
but->setToolTip( QString(tr("Select All (%1)")).arg(but->shortcut().toString()) );
connect( but, SIGNAL(clicked()), SLOT(selectAllWords()) );
layout->addWidget( but, 0 );
// setWindowFlags( Qt::Popup );
}
示例6: RecreateButtons
//.........这里部分代码省略.........
button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
}
//button->setToggleButton( true );
// mmueller
button->setCheckable ( true );
if(currentToolID == m_ToolManager->GetActiveToolID())
button->setChecked(true);
QString label;
if (m_GenerateAccelerators)
{
label += "&";
}
label += tool->GetName();
QString tooltip = tool->GetName();
MITK_DEBUG << tool->GetName() << ", " << label.toLocal8Bit().constData() << ", '" << tooltip.toLocal8Bit().constData();
if ( m_ShowNames )
{
/*
button->setUsesTextLabel(true);
button->setTextLabel( label ); // a label
QToolTip::add( button, tooltip );
*/
// mmueller Qt
button->setText( label ); // a label
button->setToolTip( tooltip );
// mmueller
QFont currentFont = button->font();
currentFont.setBold(false);
button->setFont( currentFont );
}
us::ModuleResource iconResource = tool->GetIconResource();
if (!iconResource.IsValid())
{
button->setIcon(QIcon(QPixmap(tool->GetXPM())));
}
else
{
us::ModuleResourceStream resourceStream(iconResource, std::ios::binary);
resourceStream.seekg(0, std::ios::end);
std::ios::pos_type length = resourceStream.tellg();
resourceStream.seekg(0, std::ios::beg);
char* data = new char[length];
resourceStream.read(data, length);
QPixmap pixmap;
pixmap.loadFromData(QByteArray::fromRawData(data, length));
QIcon* icon = new QIcon(pixmap);
delete[] data;
button->setIcon(*icon);
if (m_ShowNames)
{
if (m_LayoutColumns == 1)
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
else
button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
button->setIconSize(QSize(24, 24));
示例7: dropEvent
void FeatureTreeWidget::dropEvent(QDropEvent *event)
{
//Darstellen des Drag-Bildes
QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QPixmap pixmap;
QPoint offset;
dataStream >> pixmap >> offset;
QTreeWidgetItem *item = itemAt(event->pos().x(),event->pos().y());
//wenn auf ein TreeWidgetItem gedropt und dieses ein Blattknoten ist
if (item!=0)
{
if (item->childCount()==0){
mainWindow->questionDialog->writeToLog("assignColor<1>");
Feature *f = getCorrespondingFeature(item->text(0));
//Color *c = new Color (selected->color.convertTo(QColor::Hsv));
Color *c = static_cast<MyListWidgetItem*>(listWidget->selectedItems().at(0))->getBGColor();
if (item->backgroundColor(0).isValid())
mainWindow->removeColorAssignment(static_cast<MyTreeWidgetItem*>(item));
colorManager->setColorForFeature(f,c);
//X zum Abwählen der Farbe setzen
if (itemWidget(item, 1))
itemWidget(item, 1)->show();
else{
QToolButton *deleteButton = new QToolButton(this);
deleteButton->setFont(QFont(QString("MS Shell Dlg 2"),9,10,false));
//deleteButton->setFixedSize(15,18);
deleteButton->setFixedWidth(16);
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/cross.png")),QIcon::Normal,QIcon::On);
deleteButton->setIcon(icon);
deleteButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setItemWidget(item,1,deleteButton);
connect(deleteButton,SIGNAL(clicked()),this,SLOT(removeColorAssignment()));
}
//aktualisiere SmvTreeWidget und TextEdit
mainWindow->updateSMVTreeTexture(f);
redrawListWidget();
//wenn Farbe schon in FeatureTreeWidget vorhanden, setze diese auf weiß/transparent
QList <QTreeWidgetItem*> *treeList = new QList <QTreeWidgetItem*>();
findBackGroundColor(c->color,root,treeList);
if (treeList->isEmpty()==false)
{
for (int i = 0;i < treeList->size();i++){
static_cast<MyTreeWidgetItem*>(treeList->at(i))->setBackgroundInvalid();
// treeList->at(i)->background(0).setStyle(Qt::NoBrush);
// treeList->at(i)->setBackgroundColor(0,QColor(0,0,0,0));
colorManager->deleteColorForFeature(getCorrespondingFeature(treeList->at(i)->text(0)));
}
}
//setze Farbe im FeatureTreeWidget
static_cast<MyTreeWidgetItem*>(item)->setBGColor(c);
//item->setBackgroundColor(0,selected->color);
}
event->ignore();
}
}
示例8: assignAutomatically
void FeatureTreeWidget::assignAutomatically(){
QString size = "";
size = size.setNum(selectedItems().size());
mainWindow->questionDialog->writeToLog("assignColor<" + size + ">");
//schon zugewiesene Farben löschen
for (int i = 0; i < selectedItems().size();i++){
MyTreeWidgetItem *item = static_cast<MyTreeWidgetItem*>(selectedItems().at(i));
if (item->backgroundColor(0).isValid()){
MyListWidgetItem *listItem = new MyListWidgetItem(QString(""));
listItem->setBGColor(item->getBGColor());
//Icon wichtig, damit Item überhaupt angezeigt wird!
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/leer.png")),QIcon::Normal,QIcon::On);
listItem->setIcon(icon);
listWidget->addItem(listItem);
colorManager->deleteColorForFeature(getCorrespondingFeature(item->text(0)));
//item->setBackgroundColor(0,QColor(-1,-1,-1,-1));
item->setBackgroundInvalid();
itemWidget(item,1)->hide();
}
}
int cnt = 0;
if (selectedItems().size() <= listWidget->count())
cnt = selectedItems().size();
else
cnt = listWidget->count();
//nacheinander jedem ausgewählten Knoten, möglichst unterschiedliche Farben des ListWidgets zuweisen
QList <Color*> *colors = new QList<Color*>();
int step = 0;
if (cnt >1) //Division durch 0 verhindern
step = (listWidget->count()-1)/(cnt-1);
else
step = 0;
//Farben unterschiedlicher wählen
if (step < selectedItems().size()/15)
step = selectedItems().size()/15;
//Farbliste füllen
if (cnt > 1){
for (int i = 0;i < cnt;i++){
int add = 0;
while (colors->contains(static_cast<MyListWidgetItem*>(listWidget->item((i*step + add)%listWidget->count()))->getBGColor())){
add++;
}
colors->push_back(static_cast<MyListWidgetItem*>(listWidget->item((i*step + add)%listWidget->count()))->getBGColor());
}
}else{
int random = rand() % listWidget->count();
colors->push_back(static_cast<MyListWidgetItem*>(listWidget->item(random))->getBGColor());
}
for (int i = 0; i < cnt;i++){
QTreeWidgetItem *item = selectedItems().at(i);
Feature *f = getCorrespondingFeature(item->text(0));
//Color *c = static_cast<MyListWidgetItem*>(listWidget->item(0))->getBGColor();
Color *c = colors->at(i);
colorManager->setColorForFeature(f,c);
//aktualisiere SmvTreeWidget und TextEdit
mainWindow->updateSMVTreeTexture(f);
//X zum Abwählen der Farbe setzen
if (itemWidget(item, 1))
itemWidget(item, 1)->show();
else{
QToolButton *deleteButton = new QToolButton(this);
deleteButton->setFont(QFont(QString("MS Shell Dlg 2"),9,10,false));
//deleteButton->setFixedSize(15,18);
deleteButton->setFixedWidth(16);
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/cross.png")),QIcon::Normal,QIcon::On);
deleteButton->setIcon(icon);
deleteButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setItemWidget(item,1,deleteButton);
connect(deleteButton,SIGNAL(clicked()),this,SLOT(removeColorAssignment()));
}
//wenn Farbe schon in FeatureTreeWidget vorhanden, setze diese auf weiß/transparent
QList <QTreeWidgetItem*> *treeList = new QList <QTreeWidgetItem*>();
findBackGroundColor(listWidget->item(0)->backgroundColor(),root,treeList);
if (treeList->isEmpty()==false)
{
for (int i = 0;i < treeList->size();i++){
static_cast<MyTreeWidgetItem*>(treeList->at(i))->setBackgroundInvalid();
// treeList->at(i)->background(0).setStyle(Qt::NoBrush);
// treeList->at(i)->setBackgroundColor(0,QColor(0,0,0,0));
colorManager->deleteColorForFeature(getCorrespondingFeature(treeList->at(i)->text(0)));
}
}
//setze Farbe im FeatureTreeWidget
static_cast<MyTreeWidgetItem*>(item)->setBGColor(c);
//.........这里部分代码省略.........