当前位置: 首页>>代码示例>>C++>>正文


C++ QToolButton::iconSize方法代码示例

本文整理汇总了C++中QToolButton::iconSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::iconSize方法的具体用法?C++ QToolButton::iconSize怎么用?C++ QToolButton::iconSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QToolButton的用法示例。


在下文中一共展示了QToolButton::iconSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: eventFilter

bool UIControllerSetting::eventFilter( QObject* object, QEvent* event )
{
	if ( event->type() == QEvent::Paint )
	{
		QToolButton* tb = qobject_cast<QToolButton*>( object );
		
		if ( tb )
		{
			if ( tb->isChecked() )
			{
				QStylePainter sp( tb );
				QStyleOptionToolButton options;
				
				options.initFrom( tb );
				options.arrowType = Qt::NoArrow;
				options.features = QStyleOptionToolButton::None;
				options.icon = tb->icon();
				options.iconSize = tb->iconSize();
				options.state = QStyle::State_Enabled | QStyle::State_HasFocus | QStyle::State_On | QStyle::State_AutoRaise;
				
				sp.drawComplexControl( QStyle::CC_ToolButton, options );
				
				return true;
			}
		}
	}
	
	return false;
}
开发者ID:cano159,项目名称:yabause,代码行数:29,代码来源:UIControllerSetting.cpp

示例2: setForeground

void ColorDialog::setForeground()
{
    QColor color = QColorDialog::getColor(fg);
    if (color.isValid()) {
        QToolButton *button = static_cast<QToolButton *>(sender());
        button->setIcon(createIcon(button->iconSize(), color));
        fg = color;
    }
}
开发者ID:SaschaHeyer,项目名称:Qt-Code-Editor,代码行数:9,代码来源:colordialog.cpp

示例3: updateIcon

void KoColorPopupAction::updateIcon()
{
    QSize iconSize;
    QToolButton *toolButton = dynamic_cast<QToolButton*>(parentWidget());
    if (toolButton) {
        iconSize = QSize(toolButton->iconSize());
    } else {
        iconSize = QSize(16, 16);
    }

    // This must be a QImage, as drawing to a QPixmap outside the
    // UI thread will cause sporadic crashes.
    QImage pm;

    if (icon().isNull()) {
        d->applyMode = false;
    }

    if(d->applyMode) {
        pm = icon().pixmap(iconSize).toImage();
        if (pm.isNull()) {
            pm = QImage(iconSize, QImage::Format_ARGB32_Premultiplied);
            pm.fill(Qt::transparent);
        }
        QPainter p(&pm);
        p.fillRect(0, iconSize.height() - 4, iconSize.width(), 4, d->currentColor.toQColor());
        p.end();
    } else {
        pm = QImage(iconSize, QImage::Format_ARGB32_Premultiplied);
        pm.fill(Qt::transparent);
        QPainter p(&pm);
        d->checkerPainter.paint(p, QRect(QPoint(),iconSize));
        p.fillRect(0, 0, iconSize.width(), iconSize.height(), d->currentColor.toQColor());
        p.end();
    }
    setIcon(QIcon(QPixmap::fromImage(pm)));
}
开发者ID:KDE,项目名称:krita,代码行数:37,代码来源:KoColorPopupAction.cpp

示例4: QDialog

ColorDialog::ColorDialog(const QColor &foreground, const QColor &background,
                         const QVector<QColor> &colors, const QStringList &names, QWidget *parent)
    : QDialog(parent)
{
    bg = background;
    fg = foreground;
    colorList = colors;
    mapper = new QSignalMapper(this);

    QGroupBox *buttonGroupBox = new QGroupBox(tr("Highlighting colors"));
    QGridLayout *buttonLayout = new QGridLayout;

    for (int i = 0; i < colors.size(); ++i) {
        QLabel *label = new QLabel(names[i]);
        QToolButton *button = new QToolButton;
        button->setText(tr("Choose..."));
        button->setIcon(createIcon(button->iconSize(), colors[i]));
        connect(button, SIGNAL(clicked()), mapper, SLOT(map()));
        mapper->setMapping(button, i);

        buttonLayout->addWidget(label, i, 0);
        buttonLayout->addWidget(button, i, 1);
    }

    buttonGroupBox->setLayout(buttonLayout);

    connect(mapper, SIGNAL(mapped(int)), this, SLOT(selectColor(int)));

    QGroupBox *autoColorGroupBox = new QGroupBox(tr("Base colors"));

    QLabel *foregroundLabel = new QLabel(tr("Foreground:"));
    QToolButton *foregroundButton = new QToolButton;
    foregroundButton->setText(tr("Choose..."));
    foregroundButton->setIcon(createIcon(foregroundButton->iconSize(), fg));
    QLabel *backgroundLabel = new QLabel(tr("Background:"));
    QToolButton *backgroundButton = new QToolButton;
    backgroundButton->setText(tr("Choose..."));
    backgroundButton->setIcon(createIcon(backgroundButton->iconSize(), bg));
    QPushButton *createButton = new QPushButton(tr("Create New Colors"));

    connect(foregroundButton, SIGNAL(clicked()), this, SLOT(setForeground()));
    connect(backgroundButton, SIGNAL(clicked()), this, SLOT(setBackground()));
    connect(createButton, SIGNAL(clicked()), this, SLOT(createNewColors()));

    QGridLayout *autoColorLayout = new QGridLayout;
    autoColorLayout->addWidget(foregroundLabel, 0, 0);
    autoColorLayout->addWidget(foregroundButton, 0, 1);
    autoColorLayout->addWidget(backgroundLabel, 1, 0);
    autoColorLayout->addWidget(backgroundButton, 1, 1);
    autoColorLayout->addWidget(createButton, 2, 0, 1, 2);
    autoColorGroupBox->setLayout(autoColorLayout);

    QDialogButtonBox *buttons = new QDialogButtonBox(Qt::Horizontal);
    buttons->addButton(QDialogButtonBox::Ok);
    buttons->addButton(QDialogButtonBox::Cancel);

    connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(buttonGroupBox, 0, 0, 2, 1);
    mainLayout->addWidget(autoColorGroupBox, 0, 1);
    mainLayout->addWidget(buttons, 2, 0, 1, 2);
    setLayout(mainLayout);

    setWindowTitle(tr("Configure Highlighting Colors"));
}
开发者ID:SaschaHeyer,项目名称:Qt-Code-Editor,代码行数:67,代码来源:colordialog.cpp

示例5: setColorButton

void ColorDialog::setColorButton(int index, const QColor &color)
{
    QToolButton *button = static_cast<QToolButton *>(mapper->mapping(index));
    button->setIcon(createIcon(button->iconSize(), color));
    colorList[index] = color;
}
开发者ID:SaschaHeyer,项目名称:Qt-Code-Editor,代码行数:6,代码来源:colordialog.cpp


注:本文中的QToolButton::iconSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。