MCPcopy Create free account
hub / github.com/Linloir/GraphBuilder / bigIconButton

Method bigIconButton

customWidgets.cpp:428–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426//*****************
427
428bigIconButton::bigIconButton(const QString &iconPath, const QString &description, int radius, QWidget *parent) :
429 QWidget(parent),
430 cornerRadius(radius)
431{
432 iconImg = new QPixmap(iconPath);
433
434 /* set icon label and text label */
435 icon = new QLabel(this);
436 icon->setPixmap(*iconImg);
437 icon->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
438 icon->setAlignment(Qt::AlignCenter);
439
440 QFont textFont = QFont("Corbel", 13);
441 QFontMetrics fm(textFont);
442 text = new QLabel(this);
443 text->setFont(textFont);
444 text->setText(description);
445 text->setWordWrap(true);
446 text->setMinimumHeight(fm.lineSpacing());
447 text->setAlignment(Qt::AlignCenter);
448
449 /* set indicator */
450 indicator = new QWidget(this);
451 indicator->resize(6, 6);
452 indicator->move(this->width() - 3, this->height() - 21);
453 indicator->setStyleSheet("border-radius:3px;background-color:#afafaf");
454
455 /* set background */
456 bgWidget = new QWidget(this);
457 bgWidget->resize(this->size());
458 radiusStyle = QString::asprintf("border-radius:%dpx;", cornerRadius);
459 bgWidget->setStyleSheet(radiusStyle + "background-color:#04000000");
460 bgWidget->lower();
461 bgWidget->show();
462
463 /* set layout */
464 QVBoxLayout *layout = new QVBoxLayout(this);
465 this->setLayout(layout);
466 layout->setContentsMargins(15, 35, 15, 35);
467 layout->setSpacing(15);
468 layout->addWidget(icon);
469 layout->addWidget(text);
470 layout->setAlignment(Qt::AlignCenter);
471
472 this->setMinimumHeight(200);
473}
474
475void bigIconButton::resizeEvent(QResizeEvent *event){
476 bgWidget->setFixedSize(this->size());

Callers

nothing calls this directly

Calls 3

moveMethod · 0.80
addWidgetMethod · 0.80
setTextMethod · 0.45

Tested by

no test coverage detected