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


C++ QAbstractButton::setProperty方法代码示例

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


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

示例1: QWidget

DriverWidget::DriverWidget(const Device &device, QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Form)
    , m_radioGroup(new QButtonGroup(this))
{
    ui->setupUi(this);
    ui->label->setText(xi18nc("@info %1 is hardware vendor, %2 is hardware model",
                              "<title>%1 %2</title>",
                              device.vendor,
                              device.model));

    // We want to sort drivers so they have consistent order across starts.
    QList<Driver> driverList = device.drivers;
    qSort(driverList);

    foreach (const Driver &driver, driverList) {
        // This driver is not manual, but also has no package, hence we cannot
        // do anything with it and should not display anything.
        if (driver.package == nullptr && !driver.manualInstall){
            qDebug() << "encountered invalid driver" << driver.package << driver.manualInstall << "for" << device.model;
            continue;
        }

        QAbstractButton *button;
        if (driverList.count() <= 1) {
            button = new QCheckBox(this);
            m_radioGroup->setExclusive(false);
        } else {
            button = new QRadioButton(this);
        }
        button->setProperty("package", driver.packageName);
        button->setProperty("builtin", driver.builtin);
        ui->verticalLayout->addWidget(button);
        m_radioGroup->addButton(button);

        if (driver.fuzzyActive) {
            button->setChecked(true);
        }

        if (driver.manualInstall) {
            button->setText(i18nc("Manually installed 3rd party driver",
                                  "This device is using a manually-installed driver : (%1)",
                                  driver.packageName));
            break; // Manually installed drivers have no additional information available.
        }

        if (driver.recommended) {
            button->setText(i18nc("%1 is description and %2 is package name; when driver is recommended for use",
                                  "Using %1 from %2 (Recommended Driver)",
                                  driver.package->shortDescription(),
                                  driver.package->name()));
        } else { // !recommended
            button->setText(i18nc("%1 is description and %2 is package name",
                                  "Using %1 from %2",
                                  driver.package->shortDescription(),
                                  driver.package->name()));
        }

        if (driver.free) {
            button->setToolTip(i18nc("The driver is under a open source license",
                                     "Open Source Driver"));
        } else { // !free
            button->setToolTip(i18nc("The driver is under a proprietary license",
                                     "Proprietary Driver"));
        }
    }

    m_indexSelected = m_radioGroup->checkedId();
    m_defaultSelection = m_indexSelected;
    connect(m_radioGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(selectionChanged()));
}
开发者ID:KDE,项目名称:kubuntu-driver-kcm,代码行数:71,代码来源:DriverWidget.cpp


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