本文整理汇总了C++中setCheckable函数的典型用法代码示例。如果您正苦于以下问题:C++ setCheckable函数的具体用法?C++ setCheckable怎么用?C++ setCheckable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCheckable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QAction
QAction* CodeNavigator::configMenu(QWidget *parent)
{
static QAction *configAction = nullptr;
if (!configAction) {
configAction = new QAction(QIcon::fromTheme(QStringLiteral("applications-development")), QObject::tr("Code Navigation"), parent);
auto menu = new QMenu(parent);
auto group = new QActionGroup(parent);
group->setExclusive(true);
QSettings settings;
settings.beginGroup(QStringLiteral("CodeNavigator"));
const auto currentIdx = settings.value(QStringLiteral("IDE"), -1).toInt();
for (int i = 0; i < ide_settings_size; ++i) {
auto action = new QAction(menu);
action->setText(QObject::tr(ide_settings[i].name));
if (ide_settings[i].icon)
action->setIcon(QIcon::fromTheme(ide_settings[i].icon));
action->setCheckable(true);
action->setChecked(currentIdx == i);
action->setData(i);
action->setEnabled(!QStandardPaths::findExecutable(ide_settings[i].app).isEmpty());
group->addAction(action);
menu->addAction(action);
}
menu->addSeparator();
auto action = new QAction(menu);
action->setText(QObject::tr("Custom..."));
action->setCheckable(true);
action->setChecked(currentIdx == -1);
group->addAction(action);
menu->addAction(action);
QObject::connect(group, &QActionGroup::triggered, [parent](QAction *action) {
QSettings settings;
settings.beginGroup(QStringLiteral("CodeNavigator"));
if (!action->data().isValid()) {
const auto customCmd = QInputDialog::getText(
parent, QObject::tr("Custom Code Navigation"),
QObject::tr("Specify command to use for code navigation, '%f' will be replaced by the file name, '%l' by the line number."),
QLineEdit::Normal, settings.value(QStringLiteral("CustomCommand")).toString()
);
if (!customCmd.isEmpty()) {
settings.setValue(QStringLiteral("CustomCommand"), customCmd);
settings.setValue(QStringLiteral("IDE"), -1);
}
return;
}
const auto defaultIdx = action->data().toInt();
settings.setValue(QStringLiteral("IDE"), defaultIdx);
});
configAction->setMenu(menu);
}
return configAction;
}
示例2: parser
//*****************************************************************************
bool Kwave::MenuItem::specialCommand(const QString &command)
{
Kwave::Parser parser(command);
if (command == _("#checkable")) {
// checking/selecting of the item (non-exclusive)
setCheckable(true);
}
else if (parser.command() == _("#exclusive")) {
// join to a list of groups
QString group = parser.firstParam();
while (group.length()) {
if (!m_exclusive_group.length()) {
m_exclusive_group = group;
joinGroup(group, Kwave::MenuGroup::EXCLUSIVE);
} else if (m_exclusive_group != group) {
qWarning("menu item '%s' already member of "
"exclusive group '%s'",
DBG(name()), DBG(m_exclusive_group));
}
group = parser.nextParam();
}
// make the item checkable
setCheckable(true);
return true;
}
else if (command == _("#hidden")) {
setVisible(false);
}
return (Kwave::MenuNode::specialCommand(command));
}
示例3: QToolButton
DesktopSwitchButton::DesktopSwitchButton(QWidget * parent, int index, const QString &path, const QString &shortcut, const QString &title)
: QToolButton(parent)
, m_shortcut(0)
, mIndex(index)
{
setText(QString::number(index + 1));
setCheckable(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
if (!shortcut.isEmpty())
{
QString description = tr("Switch to desktop %1").arg(index + 1);
if (!title.isEmpty())
{
description.append(QString(" (%1)").arg(title));
}
m_shortcut = GlobalKeyShortcut::Client::instance()->addAction(QString(), path, description, this);
if (m_shortcut)
{
if (m_shortcut->shortcut().isEmpty())
m_shortcut->changeShortcut(shortcut);
connect(m_shortcut, SIGNAL(activated()), this, SIGNAL(activated()));
}
}
if (!title.isEmpty())
{
setToolTip(title);
}
}
示例4: m_id
StelShortcut::StelShortcut(const QString &id,
StelShortcutGroup* group,
const QString &text,
const QString &primaryKey,
const QString &altKey,
bool checkable,
bool autoRepeat,
bool global,
QGraphicsWidget *parent) :
m_id(id), m_temporary(false)
{
if (parent == NULL)
{
parent = StelMainGraphicsView::getInstance().getStelAppGraphicsWidget();
}
m_action = new QAction(parent);
m_action->setObjectName(id);
m_group = group;
setText(text);
setPrimaryKey(primaryKey);
setAltKey(altKey);
setCheckable(checkable);
setAutoRepeat(autoRepeat);
setGlobal(global);
parent->addAction(m_action);
}
示例5: QPushButton
void PageNavigator::makeNumberedButtons()
{
for (QAbstractButton * button : m_buttonGroup->buttons().toVector().toStdVector()) {
m_buttonGroup->removeButton(button);
if(button) {
delete button;
button = nullptr;
}
}
int id = 0;
QString num;
for(int i = 0; i < m_numPagesListed; ++i)
{
auto button = new QPushButton();
button->setText(num.setNum(i+1));
button->setFixedSize(40,20);
button->setCheckable(true);
m_buttonLayout->addWidget(button);
m_buttonGroup->addButton(button);
m_buttonGroup->setId(button, id++);
}
if(m_buttonGroup->button(0)) {
m_buttonGroup->button(0)->setChecked(true);
}
OS_ASSERT(m_numPagesListed == m_buttonGroup->buttons().size());
}
示例6: QPushButton
CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const QString& tooltip,
QWidget *parent)
: QPushButton (icon, "", parent), mKeepOpen (false), mType (type), mToolTip (tooltip)
{
setCheckable (type==Type_Mode);
setExtendedToolTip (tooltip);
}
示例7: QPushButton
void PatVerticalTabWidget::addTab( int id,
QString toolTip,
const QString & selectedImagePath,
const QString & unSelectedImagePath,
const QString & disabledImagePath,
const QString & doneImagePath,
bool enabled )
{
auto button = new QPushButton(m_tabBar);
button->setFixedSize(QSize(39,42));
button->setToolTip(toolTip);
button->setCheckable(true);
button->setEnabled(enabled);
m_buttonGroup->addButton(button);
m_buttonGroup->setId(button,m_buttonGroup->buttons().size() - 1);
m_selectedPixmaps.push_back(selectedImagePath);
m_unSelectedPixmaps.push_back(unSelectedImagePath);
m_disabledPixmaps.push_back(disabledImagePath);
m_donePixmaps.push_back(doneImagePath);
setCurrentIndex(0);
}
示例8: QGroupBox
QFESPIMB040SimpleCameraConfig::QFESPIMB040SimpleCameraConfig(QWidget* parent):
QGroupBox(parent)
{
m_camViewID=0;
m_extManager=NULL;
camView=NULL;
locked=false;
restartPreview=false;
m_magnification=1;
m_lastUserPreview="";
// initialize raw image memory ...
viewData.reset();
// create widgets and actions
createWidgets();
createActions();
displayStates(QFESPIMB040SimpleCameraConfig::Disconnected);
if (cmbAcquisitionDevice->count()<=0) displayStates(QFESPIMB040SimpleCameraConfig::Inactive);
init(0, NULL, "", NULL);
setCheckable(true);
setChecked(true);
}
示例9:
// Slots
//============================================================
// Connected to this->customContextMenuRequested
void Chain::Chain_Tableview::slot_customContextMenuRequested(QPoint const& pos)
{
// Assume this has the right model type and cast to it
Chain_Table_Model* true_model = static_cast<Chain_Table_Model*>(this->model());
// Get the index at the given position
QModelIndex index = this->indexAt(pos);
// If the model correct and not nullptr, and the index we're at is within the chain data
if (true_model && true_model->is_within_chain(index))
{
// Make a context menu
QMenu context_menu{};
// Add an action as a title that is the tooltip (date) of the given data point
context_menu.addAction(true_model->get_tooltip(index))->setEnabled(false);
context_menu.addSeparator();
// Make an action for setting the data and capture the pointer to it
auto did_stuff_action = context_menu.addAction("Did Stuff?");
// Make that action checkable and set its state to that of the data
did_stuff_action->setCheckable(true);
did_stuff_action->setChecked(true_model->link_did_stuff(index));
// Connect the action to a lambda that will set the data appropriately when the action is triggered
QObject::connect(did_stuff_action, &QAction::toggled,
[true_model, &index] (bool state) { true_model->set_link_did_stuff(index, state); } );
// Execute the menu at the cursor position
context_menu.exec(QCursor::pos());
// this one isn't putting the menu in the right place.
//context_menu.exec(this->mapToGlobal(pos));
}
}
示例10: QCommandLinkButton
GameButton::GameButton(int width, QString nom, QString desc, QString path, bool pwd, bool steam, QString gameID, QWidget *parent) :
QCommandLinkButton (parent),
nom (nom),
desc (desc),
path (path),
pwd (pwd),
steam (steam),
gameID (gameID),
proc (new QProcess(this))
{
//Définition de l'apparence du bouton
setMaximumSize(width / 21.875f, (width / 21.875f));
setIconSize(QSize(maximumWidth()-16, maximumHeight()-16));
setIcon(QIcon("./icons/" + nom + ".png"));
setCheckable(true);
//On définit le working directory du jeu représenté
proc->setWorkingDirectory(QFileInfo(path).absolutePath());
//connexion signaux/slots
connect(this, SIGNAL(clicked()), this, SLOT(click()));
connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
connect(proc, SIGNAL(started()), this, SLOT(started()));
connect(proc, SIGNAL(finished(int)), this, SLOT(finished(int)));
}
示例11: QPushButton
LayoutButton::LayoutButton(QString text, QWidget *parent)
: QPushButton(parent)
{
setObjectName("LayoutButton");
setCheckable(true);
m_text = text;
m_iconLabel = new QLabel(this);
QPixmap pix(":img/tick_hover.png");
m_iconLabel->setPixmap(pix);
m_iconLabel->setMinimumSize(pix.size());
m_textLabel = new QLabel;
m_textLabel->setObjectName("LayoutTextLabel");
m_textLabel->setText(text);
m_iconLabel->hide();
QHBoxLayout* m_Layout = new QHBoxLayout;
m_Layout->setContentsMargins(20, 0, 0, 0);
m_Layout->setSpacing(0);
m_Layout->addSpacing(5);
m_Layout->addWidget(m_textLabel);
m_Layout->addStretch();
setLayout(m_Layout);
m_iconLabel->move(this->x() + 5, this->y() + 4);
updateStyle(":/skin/layoutbutton.qss", this);
}
示例12: setCheckable
void QtPropertyItem::ApplyDataFlags()
{
if(NULL != itemData)
{
int dataFlags = itemData->GetFlags();
if(dataFlags & QtPropertyData::FLAG_IS_CHECKABLE)
{
setCheckable(true);
if(itemData->GetValue().toBool())
{
setCheckState(Qt::Checked);
}
}
if(dataFlags & QtPropertyData::FLAG_IS_DISABLED)
{
setEnabled(false);
}
if(dataFlags & QtPropertyData::FLAG_IS_NOT_EDITABLE)
{
setEditable(false);
}
}
}
示例13: rgba
void RoundItemButton::initUI() {
m_itemIcon->setFocusPolicy(Qt::NoFocus);
m_itemIcon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
m_itemText->setWordWrap(true);
m_itemText->setStyleSheet("color: rgba(255, 255, 255, 255);"
"font-size:16px; margin:0 5px;");
m_itemText->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
m_itemText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->addSpacing(10);
mainLayout->addWidget(m_itemIcon);
mainLayout->setAlignment(m_itemIcon, Qt::AlignHCenter);
mainLayout->addWidget(m_itemText);
setFocusPolicy(Qt::NoFocus);
setFocusPolicy(Qt::StrongFocus);
setLayout(mainLayout);
setFixedSize(QSize(140, 140));
setCheckable(true);
QGraphicsDropShadowEffect *nameShadow = new QGraphicsDropShadowEffect(m_itemText);
nameShadow->setBlurRadius(16);
nameShadow->setColor(QColor(0, 0, 0, 85));
nameShadow->setOffset(0, 4);
// m_itemText->setGraphicsEffect(nameShadow);
}
示例14: num
PokemonBoxButton::PokemonBoxButton(int num) : num(num)
{
setText(tr("e&%1").arg(num+1));
setIcon(Theme::WhiteBall());
setCheckable(true);
setAcceptDrops(true);
}
示例15: CWizToolButton
CWizToolButton(QWidget* parent = 0) : QPushButton(parent)
{
setFocusPolicy(Qt::NoFocus);
setCheckable(true);
setIconSize(QSize(24, 24));
setMaximumSize(24, 24);
}