本文整理汇总了C++中QPushButton::iconSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QPushButton::iconSize方法的具体用法?C++ QPushButton::iconSize怎么用?C++ QPushButton::iconSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPushButton
的用法示例。
在下文中一共展示了QPushButton::iconSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fm
QPushButton * ControlUnitDialog::addFunction(QString title, QIcon icon, bool checkable)
{
QPushButton *button = new QPushButton(selection_groupBox);
selButtons_verticalLayout->insertWidget(_selButtons.size(), button);
button->setFixedWidth(160);
button->setFixedHeight(35);
button->setCheckable(checkable);
button->setAutoExclusive(checkable);
// Icon:
button->setIconSize(QSize(22, 22));
button->setIcon(icon);
// Font:
QFont font = button->font();
font.setFamily(QApplication::font().family());
font.setBold(false);
font.setPixelSize(13); // 10pts
button->setFont(font);
// Text: prepend/append spaces to achieve proper icon positions:
QFontMetrics fm(font);
title = title.trimmed();
int targetstrsize = button->size().width() - button->iconSize().width() - 18;
int barestrsize = fm.size(Qt::TextShowMnemonic, title).width();
if (barestrsize < targetstrsize)
{
double spacesize = fm.size(Qt::TextShowMnemonic, " ").width();
int nspaces = static_cast<int>((targetstrsize - barestrsize) / spacesize + 0.5);
title.prepend( QString( nspaces/2, ' ' ) );
title.append( QString( nspaces - nspaces/2, ' ' ) );
}
button->setText(title);
// Save, show and return button:
button->show();
_selButtons.push_back(button);
return button;
}
示例2: pxEditHeader
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
// set working dir to executable work directory
QDir::setCurrent(QCoreApplication::applicationDirPath());
QString resDir = ResourceFinder::getPath();
//chess::FuncT *f = new chess::FuncT();
//f->run_pgn_speedtest();
//f->run_polyglot();
/*
f->run_pgnt();
f->run_pgn_scant();
*/
// reconstruct gameModel
this->gameModel = new GameModel();
this->gameModel->restoreGameState();
this->gameModel->getGame()->setTreeWasChanged(true);
this->boardViewController = new BoardViewController(gameModel, this);
this->moveViewController = new MoveViewController(gameModel, this);
this->moveViewController->setFocus();
this->engineViewController = new EngineView(gameModel, this);
engineViewController->setFocusPolicy(Qt::NoFocus);
moveViewController->setFocusPolicy(Qt::ClickFocus);
this->name = new QLabel();
name->setText("<b>Robert James Fisher - Reuben Fine</b><br/>New York(USA) 1963.03.??");
name->setAlignment(Qt::AlignCenter);
name->setBuddy(moveViewController);
QHBoxLayout *hbox_name_editHeader = new QHBoxLayout();
QPushButton *editHeader = new QPushButton();
QPixmap pxEditHeader(*this->fromSvgToPixmap(editHeader->iconSize(),resDir + "/res/icons/document-properties.svg"));
editHeader->setIcon(QIcon(pxEditHeader));
hbox_name_editHeader->addStretch(1);
hbox_name_editHeader->addWidget(this->name);
hbox_name_editHeader->addStretch(1);
hbox_name_editHeader->addWidget(editHeader);
this->uciController = new UciController();
this->modeController = new ModeController(gameModel, uciController, this);
this->editController = new EditController(gameModel, this);
this->fileController = new FileController(gameModel, this);
QSize btnSize = QSize(this->height()/19, this->height()/19);
QSize btnSizeLR = QSize(this->height()/14, this->height()/14);
QPushButton *left = new QPushButton();
QPushButton *right = new QPushButton();
QPushButton *beginning = new QPushButton();
QPushButton *end = new QPushButton();
left->setIconSize(btnSizeLR);
right->setIconSize(btnSizeLR);
beginning->setIconSize(btnSize);
end->setIconSize(btnSize);
QPixmap pxRight(*this->fromSvgToPixmap(right->iconSize(),resDir + "/res/icons/go-next.svg"));
QPixmap pxLeft(*this->fromSvgToPixmap(left->iconSize(),resDir + "/res/icons/go-previous.svg"));
QPixmap pxBeginning(*this->fromSvgToPixmap(left->iconSize(),resDir + "/res/icons/go-first.svg"));
QPixmap pxEnd(*this->fromSvgToPixmap(left->iconSize(),resDir + "/res/icons/go-last.svg"));
right->setIcon(QIcon(pxRight));
left->setIcon(QIcon(pxLeft));
beginning->setIcon(QIcon(pxBeginning));
end->setIcon(QIcon(pxEnd));
QWidget *mainWidget = new QWidget();
// setup the main window
// consisting of:
//
// <-------menubar---------------------------->
// <chess- -> <label w/ game data ->
// <board -> <moves_edit_view---------->
// <view -> <engine output view ->
QSizePolicy *spLeft = new QSizePolicy();
spLeft->setHorizontalStretch(1);
QSizePolicy *spRight = new QSizePolicy();
spRight->setHorizontalStretch(2);
QHBoxLayout *hbox_buttons = new QHBoxLayout();
hbox_buttons->addStretch(1);
hbox_buttons->addWidget(beginning);
hbox_buttons->addWidget(left);
hbox_buttons->addWidget(right);
hbox_buttons->addWidget(end);
hbox_buttons->addStretch(1);
QHBoxLayout *hbox_right_engine_buttons = new QHBoxLayout();
this->pbEngineOnOff = new OnOffButton(this); //new QPushButton("OFF");
this->lblMultiPv = new QLabel(this->tr("Lines:"), this);
this->spinMultiPv = new QSpinBox(this);
//.........这里部分代码省略.........
示例3: p
ImageFileDialog::ImageFileDialog(const QVariantList &old, QString imgpath, QWidget *parent)
:QDialog(parent),
sellist(new QListWidget()),
flistview(new QListWidget()),
treefile(new QTreeView()),
statusBar(new QLabel(this)),
okbtn(new QPushButton("确定",this))
{
mWindow = (MainWindow*)parent;
setWindowFlags(Qt::Widget | Qt::FramelessWindowHint);
setModal(true);
treefile->header()->setHidden(true);
flistview->setProperty(DKEY_EXTMAP,extMap);
/* 填弃上一次的数据 */
dirModel = new QFileSystemModel(this);
fileModel = new QFileSystemModel(this);
this->setFixedSize(1000,600);
sellist->setSelectionMode(QAbstractItemView::ExtendedSelection);
sellist->setAlternatingRowColors(true);
flistview->setSelectionMode(QAbstractItemView::ExtendedSelection);
flistview->setAlternatingRowColors(true);
flistview->setIconSize(QSize(80,60));
sellist->setIconSize(QSize(80,60));
QMap<QString,QString> navigator;
navigator[UP] = ":/icon/icons/go-up.png";
navigator[DOWN] = ":/icon/icons/go-down.png";
navigator[LEFT] = ":/icon/icons/go-previous.png";
navigator[RIGHT] = ":/icon/icons/go-next.png";
QVBoxLayout *mainLayout = new QVBoxLayout();
QHBoxLayout *mh = new QHBoxLayout();
this->setLayout(mainLayout);
mainLayout->addLayout(mh);
this->setWindowTitle(tr("图片编辑"));
QVBoxLayout *v = new QVBoxLayout();
v->setSizeConstraint(QLayout::SetFixedSize);
QMapIterator<QString,QString> itmap(navigator);
while(itmap.hasNext())
{
itmap.next();
QPushButton *btn = new QPushButton();
QPixmap p(itmap.value());
btn->setIconSize(p.size());
p.setMask(p.createMaskFromColor(Qt::white));
btn->setIcon(QIcon(p));
btn->setObjectName(itmap.key());
btn->setFixedSize(btn->iconSize());
v->addWidget(btn);
if(!LEFT.compare(itmap.key()))
{
connect(btn,SIGNAL(clicked(bool)),SLOT(onAddSelectedItems()));
}else if(!UP.compare(itmap.key()))
{
connect(btn,SIGNAL(clicked(bool)),SLOT(onUp()));
}else if(!DOWN.compare(itmap.key()))
{
connect(btn,SIGNAL(clicked(bool)),SLOT(onDown()));
}else if(!RIGHT.compare(itmap.key()))
{
connect(btn,SIGNAL(clicked(bool)),SLOT(onDelSelectedItems()));
}
}
dirModel->setRootPath(imgpath);
dirModel->removeColumn(3);
dirModel->removeColumn(2);
dirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
filters << "*.bmp" << "*.png" << "*.jpg";
dirModel->setNameFilters(filters);
treefile->setModel(dirModel);
treefile->setRootIndex(dirModel->index(imgpath));
treefile->setAlternatingRowColors(true);
treefile->hideColumn(3);
treefile->hideColumn(2);
treefile->hideColumn(1);
fileModel->setRootPath(imgpath);
fileModel->setNameFilters(filters);
fileModel->setFilter(QDir::Files);
connect(sellist,&QListWidget::clicked,
[=](QModelIndex index){
sellist->clearSelection();
sellist->setCurrentIndex(index);
//.........这里部分代码省略.........