本文整理汇总了C++中QAbstractButton类的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractButton类的具体用法?C++ QAbstractButton怎么用?C++ QAbstractButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QAbstractButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
//! [1]
Counter a, b;
//! [1] //! [2]
QObject::connect(&a, SIGNAL(valueChanged(int)),
&b, SLOT(setValue(int)));
//! [2]
//! [3]
a.setValue(12); // a.value() == 12, b.value() == 12
//! [3] //! [4]
b.setValue(48); // a.value() == 12, b.value() == 48
//! [4]
QWidget *widget = reinterpret_cast<QWidget *>(new QObject(0));
//! [5]
if (widget->inherits("QAbstractButton")) {
QAbstractButton *button = static_cast<QAbstractButton *>(widget);
button->toggle();
//! [5] //! [6]
}
//! [6]
//! [7]
if (QAbstractButton *button = qobject_cast<QAbstractButton *>(widget))
button->toggle();
//! [7]
}
示例2: getGuiValue
virtual dyn_t getGuiValue(void){
QAbstractButton *button = dynamic_cast<QAbstractButton*>(_widget);
if (button!=NULL)
return DYN_create_bool(button->isChecked());
QAbstractSlider *slider = dynamic_cast<QAbstractSlider*>(_widget);
if (slider!=NULL)
return DYN_create_int(slider->value());
QLabel *label = dynamic_cast<QLabel*>(_widget);
if (label!=NULL)
return DYN_create_string(label->text());
QLineEdit *line_edit = dynamic_cast<QLineEdit*>(_widget);
if (line_edit!=NULL)
return DYN_create_string(line_edit->text());
QTextEdit *text_edit = dynamic_cast<QTextEdit*>(_widget);
if (text_edit!=NULL)
return DYN_create_string(text_edit->toPlainText());
QSpinBox *spinbox = dynamic_cast<QSpinBox*>(_widget);
if (spinbox!=NULL)
return DYN_create_int(spinbox->value());
QDoubleSpinBox *doublespinbox = dynamic_cast<QDoubleSpinBox*>(_widget);
if (doublespinbox!=NULL)
return DYN_create_float(doublespinbox->value());
handleError("Gui #%d does not have a getValue method", _gui_num);
return DYN_create_bool(false);
}
示例3: Q_Q
void QDockWidgetPrivate::init()
{
Q_Q(QDockWidget);
QDockWidgetLayout *layout = new QDockWidgetLayout(q);
layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
QAbstractButton *button = new QDockWidgetTitleButton(q);
button->setObjectName(QLatin1String("qt_dockwidget_floatbutton"));
QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_toggleTopLevel()));
layout->setWidgetForRole(QDockWidgetLayout::FloatButton, button);
button = new QDockWidgetTitleButton(q);
button->setObjectName(QLatin1String("qt_dockwidget_closebutton"));
QObject::connect(button, SIGNAL(clicked()), q, SLOT(close()));
layout->setWidgetForRole(QDockWidgetLayout::CloseButton, button);
resizer = new QWidgetResizeHandler(q);
resizer->setMovingEnabled(false);
resizer->setActive(false);
#ifndef QT_NO_ACTION
toggleViewAction = new QAction(q);
toggleViewAction->setCheckable(true);
fixedWindowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q);
toggleViewAction->setText(fixedWindowTitle);
QObject::connect(toggleViewAction, SIGNAL(triggered(bool)),
q, SLOT(_q_toggleView(bool)));
#endif
updateButtons();
}
示例4: QDialog
// constructor
LineObjectDialog::LineObjectDialog (QWidget * parent):
QDialog (parent), ui (new Ui::LineObjectDialog)
{
QAbstractButton *button;
ui->setupUi (this);
this->setWindowFlags(Qt::CustomizeWindowHint);
color = Qt::white;
pixmap = new QPixmap (16, 16);
icon = new QIcon;
pixmap->fill (color);
icon->addPixmap (*pixmap, QIcon::Normal, QIcon::On);
ui->colorButton->setIcon (*icon);
#ifdef Q_OS_WIN
colorDialog = new QColorDialog (this);
#else
colorDialog = new QColorDialog; // (this);
#endif
colorDialog->setModal (true);
foreach (button, ui->buttonBox->buttons ())
button->setFocusPolicy (Qt::NoFocus);
connect(ui->colorButton, SIGNAL(clicked (bool)), this, SLOT(color_clicked(void)));
connect (colorDialog, SIGNAL (accepted ()), this, SLOT (colorDialog_accepted ()));
connect(ui->buttonBox, SIGNAL(accepted ()), this, SLOT(ok_clicked ()));
connect(ui->buttonBox, SIGNAL(rejected ()), this, SLOT(cancel_clicked ()));
correctWidgetFonts (this);
}
示例5: registerClick
void StatsWatcher::registerClick(bool checked)
{
QString statMessage;
QAbstractButton *button = qobject_cast<QAbstractButton*>(sender());
if (button)
{
if (button->isCheckable())
{
if (checked)
{
statMessage = "S'ha activat amb un click el botó";
}
else
{
statMessage = "S'ha desactivat amb un click el botó";
}
}
else
{
statMessage = "Sha fet un click sobre el botó";
}
}
// És un altre tipus d'objecte
else
{
statMessage = "S'ha fet un click sobre l'objecte";
}
statMessage = QString("[%1] %2 %3").arg(m_context).arg(statMessage).arg(sender()->objectName());
log(statMessage);
}
示例6: refreshIcons
void PatVerticalTabWidget::refreshIcons()
{
for(int i = 0; i < m_buttonGroup->buttons().size(); i++)
{
// TODO "done" not handled
//imagePath = m_donePixmaps[i];
QAbstractButton * button = m_buttonGroup->button(i);
QString imagePath;
if(button->isEnabled() && button->isChecked()){
imagePath = m_selectedPixmaps[i];
}
else if(button->isEnabled() && !button->isChecked()){
imagePath = m_unSelectedPixmaps[i];
}
else if(!button->isEnabled() && button->isChecked()){
imagePath = m_selectedPixmaps[i];
}
else if(!button->isEnabled() && !button->isChecked()){
imagePath = m_disabledPixmaps[i];
}
else{
// you should not be here
OS_ASSERT(false);
}
QString style;
style.append("QPushButton { background-color: blue; background-image: url(\"");
style.append(imagePath);
style.append("\"); border: none; background-repeat: 0; }");
button->setStyleSheet(style);
}
}
示例7: pos
void HoveringButtonsController::ForwardMouseClickEvent(float x, float y)
{
// To widgetspace
float x_widgetspace = x*(float)this->width();
float y_widgetspace = y*(float)this->height();
QPoint pos(x_widgetspace,y_widgetspace);
QMouseEvent e(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(this, &e);
// Iterate through buttons and check if they are pressed
for(int i = 0; i< layout()->count();i++)
{
QLayoutItem* item = layout()->itemAt(i);
QAbstractButton *button = dynamic_cast<QAbstractButton*>(item->widget());
if(button)
{
if(button->rect().contains(button->mapFromParent(pos)))
{
QMouseEvent e(QEvent::MouseButtonPress, pos - button->pos(),pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(button, &e);
}
}
}
}
示例8: MythPopupBox
void EditMetadataDialog::showSaveMenu()
{
popup = new MythPopupBox(GetMythMainWindow(), "Menu");
QLabel *label = popup->addLabel(tr("Save Changes?"), MythPopupBox::Large, false);
label->setAlignment(Qt::AlignCenter | Qt::WordBreak);
QAbstractButton *topButton;
if (metadataOnly)
{
topButton = popup->addButton(tr("Save Changes"), this,
SLOT(saveToMetadata()));
}
else
{
topButton = popup->addButton(tr("Save Changes"), this,
SLOT(saveAll()));
}
popup->addButton(tr("Exit/Do Not Save"), this,
SLOT(closeDialog()));
popup->addButton(tr("Cancel"), this, SLOT(cancelPopup()));
popup->ShowPopup(this, SLOT(cancelPopup()));
topButton->setFocus();
}
示例9: getSelectedName
QString KSaneDeviceDialog::getSelectedName() {
QAbstractButton *selectedButton = m_btnGroup->checkedButton();
if(selectedButton) {
return selectedButton->objectName();
}
return QString();
}
示例10: QDialog
XMLInfoDialog::XMLInfoDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::XMLInfoDialog)
{
ui->setupUi(this);
setWindowTitle(tr("选择订阅"));
setMinimumWidth(400);
setMinimumHeight(450);
setMaximumWidth(400);
setMaximumHeight(450);
QAbstractButton *okBtn = ui->buttonBox->button(QDialogButtonBox::Ok);
QAbstractButton *cancelBtn = ui->buttonBox->button(QDialogButtonBox::Cancel);
okBtn->setText(tr("确定"));
cancelBtn->setText(tr("取消"));
connect(cancelBtn, SIGNAL(clicked(bool)), this, SLOT(close()));
connect(okBtn, SIGNAL(clicked(bool)), this, SLOT(subscriptionSelectedFinished()));
QHeaderView *header = new QHeaderView(Qt::Horizontal, ui->treeWidget);
header->setSectionResizeMode(QHeaderView::Stretch);
header->setDefaultAlignment(Qt::AlignCenter);
ui->treeWidget->setHeader(header);
connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(treeItemChanged(QTreeWidgetItem*,int)));
}
示例11: InitializeDataNodeFromQButtonGroup
static void
InitializeDataNodeFromQButtonGroup(QButtonGroup *co, DataNode *node)
{
std::string objectName(co->objectName().toStdString());
DataNode *currentNode = node->GetNode(objectName);
QAbstractButton *sb = co->checkedButton();
if(currentNode != 0)
{
// Use int or string, depending on what the node was initially.
NodeTypeEnum t = currentNode->GetNodeType();
node->RemoveNode(objectName);
if(t == STRING_NODE)
{
if(sb != 0)
node->AddNode(new DataNode(objectName, sb->text().toStdString()));
else
node->AddNode(new DataNode(objectName, int(0)));
}
else
{
int index = sb ? co->id(sb) : 0;
node->AddNode(new DataNode(objectName, index));
}
}
else
{
// There's no preference on which type to use so use int
int index = sb ? co->id(sb) : 0;
node->AddNode(new DataNode(objectName, index));
}
}
示例12: ui
PreferencesDialog::PreferencesDialog( QMenuBar* menuBar, QWidget* parent )
:unicorn::MainWindow( menuBar, parent ),
ui( new Ui::PreferencesDialog )
{
// Disable the minimize and maximize buttons.
Qt::WindowFlags flags = this->windowFlags();
flags &= ~Qt::WindowMinMaxButtonsHint;
setWindowFlags(flags);
ui->setupUi( this );
setAttribute( Qt::WA_DeleteOnClose, true );
static_cast<QAbstractButton*>( ui->toolBar->widgetForAction( ui->actionGeneral ) )->setAutoExclusive( true );
static_cast<QAbstractButton*>( ui->toolBar->widgetForAction( ui->actionScrobbling ) )->setAutoExclusive( true );
static_cast<QAbstractButton*>( ui->toolBar->widgetForAction( ui->actionDevices ) )->setAutoExclusive( true );
static_cast<QAbstractButton*>( ui->toolBar->widgetForAction( ui->actionAccounts ) )->setAutoExclusive( true );
static_cast<QAbstractButton*>( ui->toolBar->widgetForAction( ui->actionAdvanced ) )->setAutoExclusive( true );
connect( ui->toolBar->widgetForAction( ui->actionGeneral ), SIGNAL(toggled(bool)), ui->actionGeneral, SLOT(setChecked(bool)) );
connect( ui->toolBar->widgetForAction( ui->actionScrobbling ), SIGNAL(toggled(bool)), ui->actionScrobbling, SLOT(setChecked(bool)) );
connect( ui->toolBar->widgetForAction( ui->actionDevices ), SIGNAL(toggled(bool)), ui->actionDevices, SLOT(setChecked(bool)) );
connect( ui->toolBar->widgetForAction( ui->actionAccounts ), SIGNAL(toggled(bool)), ui->actionAccounts, SLOT(setChecked(bool)) );
connect( ui->toolBar->widgetForAction( ui->actionAdvanced ), SIGNAL(toggled(bool)), ui->actionAdvanced, SLOT(setChecked(bool)) );
connect( this, SIGNAL( saveNeeded() ), ui->general, SLOT( saveSettings() ) );
connect( this, SIGNAL( saveNeeded() ), ui->scrobbling, SLOT( saveSettings() ) );
connect( this, SIGNAL( saveNeeded() ), ui->ipod, SLOT( saveSettings() ) );
connect( this, SIGNAL( saveNeeded() ), ui->accounts, SLOT( saveSettings() ) );
connect( this, SIGNAL( saveNeeded() ), ui->advanced, SLOT( saveSettings() ) );
connect( ui->general, SIGNAL( settingsChanged() ), SLOT( onSettingsChanged() ) );
connect( ui->scrobbling, SIGNAL( settingsChanged() ), SLOT( onSettingsChanged() ) );
connect( ui->ipod, SIGNAL( settingsChanged() ), SLOT( onSettingsChanged() ) );
connect( ui->accounts, SIGNAL( settingsChanged() ), SLOT( onSettingsChanged() ) );
connect( ui->advanced, SIGNAL( settingsChanged() ), SLOT( onSettingsChanged() ) );
connect( ui->actionGeneral, SIGNAL(triggered()), SLOT(onTabButtonClicked()));
connect( ui->actionScrobbling, SIGNAL(triggered()), SLOT(onTabButtonClicked()));
connect( ui->actionDevices, SIGNAL(triggered()), SLOT(onTabButtonClicked()));
connect( ui->actionAccounts, SIGNAL(triggered()), SLOT(onTabButtonClicked()));
connect( ui->actionAdvanced, SIGNAL(triggered()), SLOT(onTabButtonClicked()));
connect( ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(onStackCurrentChanged(int)), Qt::QueuedConnection );
#ifdef Q_OS_MAC
ui->buttonBox->hide();
#endif
connect( ui->buttonBox, SIGNAL( accepted() ), SLOT( onAccepted() ) );
connect( ui->buttonBox, SIGNAL( rejected() ), SLOT( onRejected() ) );
QAbstractButton* applyButton = ui->buttonBox->button( QDialogButtonBox::Apply );
applyButton->setEnabled( false );
connect( applyButton, SIGNAL( clicked() ), SLOT( onApplyButtonClicked() ) );
setFixedWidth( 550 );
ui->stackedWidget->setCurrentWidget( ui->accounts );
ui->actionGeneral->trigger();
}
示例13: QDialog
ColorFormatDlg::ColorFormatDlg( JuffPlugin* plugin, const QColor& color, QWidget* parent) : QDialog(parent) {
_ui.setupUi( this );
_plugin = plugin;
connect( _ui.buttonBox, SIGNAL(accepted()), SLOT(accept()) );
connect( _ui.buttonBox, SIGNAL(rejected()), SLOT(reject()) );
int r, g, b;
color.getRgb( &r, &g, &b );
_ui.btnHtml->setText( color.name() );
_ui.btnHex->setText( color.name().replace("#", "0x") );
_ui.btnHexSplitted->setText( QString().sprintf("0x%02hX, 0x%02hX, 0x%02hX", r, g, b) );
_ui.btnSplitted->setText( QString().sprintf("%i, %i, %i", r, g, b) );
_ui.buttonGroup->setId( _ui.btnHtml, 0 );
_ui.buttonGroup->setId( _ui.btnHex, 1 );
_ui.buttonGroup->setId( _ui.btnHexSplitted, 2 );
_ui.buttonGroup->setId( _ui.btnSplitted, 3 );
// _ui.btnHtml->setChecked( true );
int id = PluginSettings::getInt( plugin, "format", 0 );
QAbstractButton* btn = _ui.buttonGroup->button( id );
if ( btn != 0 ) {
btn->setChecked( true );
}
else {
_ui.btnHtml->setChecked( true );
}
}
示例14: setcolormark
void setcolormark(QRgb colorval)
{
int i;
if (colorval != DEFAULTCOLOR) {
i = 3 + colorlist.indexOf(colorval);
if (i<3) return; // no such color :(
} else {
i = 2; // index of the "Inherit Color" action
}
// 1. mark the color in the menu
toggleexcl(menuAction("Elements_Color")->menu()->actions()[i]);
// 2. mark the color on the toolbar
QAbstractButton *button = toolbar->findChild<QAbstractButton*>("Colors");
int toolIndex = button->property("index").toInt();
QImage img(ToolBar[toolIndex].icon_data);
QPixmap pix(img.size());
QPainter p(&pix);
if (i==2) {
// inherit color -- default pixmap
p.drawImage(0, 0, img);
} else {
// color pixmap
p.fillRect(img.rect(), QColor(colorval));
}
button->actions().first()->setIcon(QIcon(pix));
}
示例15: QWizard
FirstRunWizard::FirstRunWizard(QWidget* parent, Qt::WindowFlags flags)
: QWizard(parent, flags)
{
setWindowTitle(tr("Shaman first run"));
addPage(new IntroPage);
addPage(new SecurityPage);
addPage(new ConfigurationPage);
#ifdef KDE4_INTEGRATION
addPage(new KDEPage);
#endif
addPage(new FinishPage);
#ifdef KDE4_INTEGRATION
QAbstractButton *bt = button(CancelButton);
bt->setIcon(KIcon("dialog-close"));
setButton(CancelButton, bt);
bt = button(BackButton);
bt->setIcon(KIcon("go-previous"));
setButton(BackButton, bt);
bt = button(NextButton);
bt->setIcon(KIcon("go-next"));
bt->setLayoutDirection(Qt::RightToLeft);
setButton(NextButton, bt);
#endif
setButtonText(CancelButton, tr("Skip wizard"));
setButtonText(NextButton, tr("Next"));
setButtonText(BackButton, tr("Back"));
}