本文整理汇总了C++中QAction::connect方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::connect方法的具体用法?C++ QAction::connect怎么用?C++ QAction::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ss
extern "C" void InitSceneSwitcher()
{
QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
obs_module_text("SceneSwitcher"));
switcher = new SwitcherData;
auto cb = [] ()
{
obs_frontend_push_ui_translation(obs_module_get_string);
QMainWindow *window =
(QMainWindow*)obs_frontend_get_main_window();
SceneSwitcher ss(window);
ss.exec();
obs_frontend_pop_ui_translation();
};
obs_frontend_add_save_callback(SaveSceneSwitcher, nullptr);
obs_frontend_add_event_callback(OBSEvent, nullptr);
action->connect(action, &QAction::triggered, cb);
}
示例2: QAction
QList< QAction * > Inputs::getAddActions()
{
QAction *actCD = new QAction( NULL );
actCD->setObjectName( "actCD" );
actCD->setIcon( QIcon( ":/cd" ) );
actCD->setText( tr( "Płyta AudioCD" ) );
actCD->connect( actCD, SIGNAL( triggered() ), this, SLOT( add() ) );
QAction *actTone = new QAction( NULL );
actTone->setObjectName( "actTone" );
actTone->setIcon( QIcon( ":/sine" ) );
actTone->setText( tr( "Generator częstotliwości" ) );
actTone->connect( actTone, SIGNAL( triggered() ), this, SLOT( add() ) );
return QList< QAction * >() << actCD << actTone;
}
示例3: dialog
extern "C" void InitCaptions()
{
QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
obs_module_text("Captions"));
captions = new obs_captions;
auto cb = [] ()
{
obs_frontend_push_ui_translation(obs_module_get_string);
QWidget *window =
(QWidget*)obs_frontend_get_main_window();
CaptionsDialog dialog(window);
dialog.exec();
obs_frontend_pop_ui_translation();
};
obs_frontend_add_save_callback(save_caption_data, nullptr);
obs_frontend_add_event_callback(obs_event, nullptr);
action->connect(action, &QAction::triggered, cb);
}
示例4: QAction
QList< QAction * > AudioCD::getAddActions()
{
QAction *actCD = new QAction(NULL);
actCD->setIcon(QIcon(":/AudioCD"));
actCD->setText(tr("AudioCD"));
actCD->connect(actCD, SIGNAL(triggered()), this, SLOT(add()));
return QList< QAction * >() << actCD;
}
示例5: QAction
QList< QAction * > Inputs::getAddActions()
{
QAction *actTone = new QAction(NULL);
actTone->setIcon(QIcon(":/sine"));
actTone->setText(tr("Tone generator"));
actTone->connect(actTone, SIGNAL(triggered()), this, SLOT(add()));
return QList< QAction * >() << actTone;
}
示例6: TaskFemConstraint
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "fem-constraint-pressure")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintPressure();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
QAction* action = new QAction(tr("Delete"), ui->lw_references);
action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
ui->lw_references->addAction(action);
ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->if_pressure, SIGNAL(valueChanged(Base::Quantity)),
this, SLOT(onPressureChanged(Base::Quantity)));
connect(ui->b_add_reference, SIGNAL(pressed()),
this, SLOT(onButtonReference()));
connect(ui->cb_reverse_direction, SIGNAL(toggled(bool)),
this, SLOT(onCheckReverse(bool)));
this->groupLayout()->addWidget(proxy);
// Temporarily prevent unnecessary feature recomputes
ui->if_pressure->blockSignals(true);
ui->lw_references->blockSignals(true);
ui->b_add_reference->blockSignals(true);
ui->cb_reverse_direction->blockSignals(true);
// Get the feature data
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
double f = pcConstraint->Pressure.getValue();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
bool reversed = pcConstraint->Reversed.getValue();
// Fill data into dialog elements
ui->if_pressure->setMinimum(0);
ui->if_pressure->setMaximum(FLOAT_MAX);
//1000 because FreeCAD used kPa internally
Base::Quantity p = Base::Quantity(1000 * f, Base::Unit::Stress);
ui->if_pressure->setValue(p);
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
}
if (Objects.size() > 0) {
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
}
ui->cb_reverse_direction->setChecked(reversed);
ui->if_pressure->blockSignals(false);
ui->lw_references->blockSignals(false);
ui->b_add_reference->blockSignals(false);
ui->cb_reverse_direction->blockSignals(false);
updateUI();
}
示例7: populate_menu
/**
* @brief Populate a QMenu from a node's menu definition called "menu_key"
* @param menu The QMenu to populate
* @param node The PlaylistNode the menu belongs to
* @param menu_key The name of the menu
*/
inline void populate_menu(QMenu &menu, PlaylistNode* node, QString menu_key)
{
for (QVariant e : node->property2<QVariantList>(menu_key))
{
QVariantMap entry = e.toMap();
QAction *a = menu.addAction(entry["text"].toString());
if (entry["action"].toString() == "call" && node->hasMethod(entry["method"].toString()))
a->connect(a, &QAction::triggered, [entry, node](){
node->call(entry["method"].toString(), entry.value("args").toList());
});
else
a->setEnabled(false);
}
}
示例8: void
QConsoleWidgetPrivate::QConsoleWidgetPrivate(
QConsoleWidget *s,QWidget *p
):
QConsoleWidgetPrivateParent(p)
{
super = s;
positionX = 0;
positionY = 0;
{//TODO: font menu
QMenu * menu = new QMenu(this);
this->setMenu(menu);
menu->setStyleSheet( MenuStyleSheet );
this->setPopupMode(QToolButton::InstantPopup);
typedef void(QAction::*AT)(bool);
{
QAction * action =
new QAction( trUtf8(u8"选择字体"), this);
action->connect(action, AT(&QAction::triggered ),
[this](bool) {
selectAndSetFont(); }
);
menu->addAction(action);
actions[0] = action;
}
{
QAction * action =
new QAction( trUtf8(u8"选择字体颜色"), this);
action->connect(action, AT(&QAction::triggered),
[this](bool) {
selectAndSetFontColor(); }
);
actions[1] = action;
menu->addAction(action);
}
}
}
示例9: TaskFemConstraint
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "fem-constraint-pressure")
{ //Note change "pressure" in line above to new constraint name
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintPressure();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
QAction* action = new QAction(tr("Delete"), ui->lw_references);
action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
ui->lw_references->addAction(action);
ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
this->groupLayout()->addWidget(proxy);
/* Note: */
// Get the feature data
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
// Fill data into dialog elements
ui->if_pressure->setMinimum(0);
ui->if_pressure->setMaximum(FLOAT_MAX);
Base::Quantity p = Base::Quantity(1000 * (pcConstraint->Pressure.getValue()), Base::Unit::Stress);
ui->if_pressure->setValue(p);
bool reversed = pcConstraint->Reversed.getValue();
ui->checkBoxReverse->setChecked(reversed);
/* */
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
}
if (Objects.size() > 0) {
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
updateUI();
}
示例10: TaskFemConstraint
TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "Fem_ConstraintFixed")
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintFixed();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
// Create a context menu for the listview of the references
QAction* action = new QAction(tr("Delete"), ui->listReferences);
action->connect(action, SIGNAL(triggered()),
this, SLOT(onReferenceDeleted()));
ui->listReferences->addAction(action);
ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->buttonReference, SIGNAL(pressed()),
this, SLOT(onButtonReference()));
this->groupLayout()->addWidget(proxy);
// Temporarily prevent unnecessary feature recomputes
ui->listReferences->blockSignals(true);
ui->buttonReference->blockSignals(true);
// Get the feature data
Fem::ConstraintFixed* pcConstraint = static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
// Fill data into dialog elements
ui->listReferences->clear();
for (int i = 0; i < Objects.size(); i++)
ui->listReferences->addItem(makeRefText(Objects[i], SubElements[i]));
if (Objects.size() > 0)
ui->listReferences->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
ui->listReferences->blockSignals(false);
ui->buttonReference->blockSignals(false);
// Selection mode can be always on since there is nothing else in the UI
onButtonReference(true);
}
示例11: InitScripts
extern "C" void InitScripts()
{
scriptLogWindow = new ScriptLogWindow();
obs_scripting_load();
obs_scripting_set_log_callback(script_log, nullptr);
QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
obs_module_text("Scripts"));
#if PYTHON_UI
config_t *config = obs_frontend_get_global_config();
const char *python_path = config_get_string(config, "Python",
"Path" ARCH_NAME);
if (!obs_scripting_python_loaded() && python_path && *python_path)
obs_scripting_load_python(python_path);
#endif
scriptData = new ScriptData;
auto cb = [] ()
{
obs_frontend_push_ui_translation(obs_module_get_string);
if (!scriptsWindow) {
scriptsWindow = new ScriptsTool();
scriptsWindow->show();
} else {
scriptsWindow->show();
scriptsWindow->raise();
}
obs_frontend_pop_ui_translation();
};
obs_frontend_add_save_callback(save_script_data, nullptr);
obs_frontend_add_preload_callback(load_script_data, nullptr);
obs_frontend_add_event_callback(obs_event, nullptr);
action->connect(action, &QAction::triggered, cb);
}
示例12: QWidget
LoadSaveState::LoadSaveState(GameController* controller, QWidget* parent)
: QWidget(parent)
, m_controller(controller)
, m_currentFocus(controller->stateSlot() - 1)
, m_mode(LoadSave::LOAD)
{
setAttribute(Qt::WA_TranslucentBackground);
m_ui.setupUi(this);
m_slots[0] = m_ui.state1;
m_slots[1] = m_ui.state2;
m_slots[2] = m_ui.state3;
m_slots[3] = m_ui.state4;
m_slots[4] = m_ui.state5;
m_slots[5] = m_ui.state6;
m_slots[6] = m_ui.state7;
m_slots[7] = m_ui.state8;
m_slots[8] = m_ui.state9;
unsigned width, height;
controller->thread()->core->desiredVideoDimensions(controller->thread()->core, &width, &height);
int i;
for (i = 0; i < NUM_SLOTS; ++i) {
loadState(i + 1);
m_slots[i]->installEventFilter(this);
m_slots[i]->setMaximumSize(width + 2, height + 2);
connect(m_slots[i], &QAbstractButton::clicked, this, [this, i]() { triggerState(i + 1); });
}
if (m_currentFocus >= 9) {
m_currentFocus = 0;
}
if (m_currentFocus < 0) {
m_currentFocus = 0;
}
QAction* escape = new QAction(this);
escape->connect(escape, SIGNAL(triggered()), this, SLOT(close()));
escape->setShortcut(QKeySequence("Esc"));
escape->setShortcutContext(Qt::WidgetWithChildrenShortcut);
addAction(escape);
}
示例13: InitOutputTimer
extern "C" void InitOutputTimer()
{
QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
obs_module_text("OutputTimer"));
obs_frontend_push_ui_translation(obs_module_get_string);
QMainWindow *window = (QMainWindow*)obs_frontend_get_main_window();
ot = new OutputTimer(window);
auto cb = [] ()
{
ot->ShowHideDialog();
};
obs_frontend_pop_ui_translation();
obs_frontend_add_save_callback(SaveOutputTimer, nullptr);
obs_frontend_add_event_callback(OBSEvent, nullptr);
action->connect(action, &QAction::triggered, cb);
}
示例14: setStandardKeys
//.........这里部分代码省略.........
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
}
}
if (!hasShortcut)
{
QDialogButtonBox* bb = widget->findChild<QDialogButtonBox*>();
if (bb)
{
QList<QAbstractButton*> buttons = bb->buttons();
for (int i = 0; i < buttons.size(); ++i)
{
QAbstractButton *bbutton = buttons.at(i);
QDialogButtonBox::ButtonRole btnrole = bb->buttonRole(buttons.at(i));
if (btnrole == QDialogButtonBox::AcceptRole)
{
bbutton->setShortcut(QKeySequence::Save);
bbutton->setToolTip(bbutton->text().remove("&") + " " +
bbutton->shortcut().toString(QKeySequence::NativeText));
}
else if (btnrole == QDialogButtonBox::RejectRole)
{
bbutton->setShortcut(QKeySequence::Close);
bbutton->setToolTip(bbutton->text().remove("&") + " " +
bbutton->shortcut().toString(QKeySequence::NativeText));
}
}
}
}
// For Close
hasShortcut = false;
button = widget->findChild<QPushButton*>("_close");
if (button)
{
button->setShortcut(QKeySequence::Close);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
hasShortcut = true;
}
if (!hasShortcut) // Because some screens have both
{
// For Post
button = widget->findChild<QPushButton*>("_cancel");
if (button)
{
button->setShortcut(QKeySequence::Close);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
}
}
// For New
button = widget->findChild<QPushButton*>("_new");
if (button)
{
button->setShortcut(QKeySequence::New);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
hasShortcut = true;
}
// For Print
button = widget->findChild<QPushButton*>("_print");
if (button)
{
button->setShortcut(QKeySequence::Print);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
hasShortcut = true;
}
// For Query
button = widget->findChild<QPushButton*>("_query");
if (button)
{
button->setShortcut(QKeySequence::Refresh);
button->setToolTip(button->text().remove("&") + " " +
button->shortcut().toString(QKeySequence::NativeText));
hasShortcut = true;
}
// Page up/down for tab widgets
QTabWidget* tab = widget->findChild<QTabWidget*>();
if (tab)
{
TabWidgetNavigtor* tabNav = new TabWidgetNavigtor(tab, widget);
QAction* pagedownAct = new QAction(tab);
pagedownAct->setShortcut(QKeySequence::MoveToNextPage);
pagedownAct->connect(pagedownAct, SIGNAL(triggered()), tabNav, SLOT(pageDown()));
tab->addAction(pagedownAct);
QAction* pageupAct = new QAction(tab);
pageupAct->setShortcut(QKeySequence::MoveToPreviousPage);
pageupAct->connect(pageupAct, SIGNAL(triggered()), tabNav, SLOT(pageUp()));
tab->addAction(pageupAct);
}
}
示例15: TaskFemConstraint
TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraintTransform *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "fem-constraint-transform")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintTransform();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
QAction* actionRect = new QAction(tr("Delete"), ui->lw_Rect);
actionRect->connect(actionRect, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
ui->lw_Rect->addAction(actionRect);
ui->lw_Rect->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
this->groupLayout()->addWidget(proxy);
connect(ui->rb_rect, SIGNAL(clicked(bool)), this, SLOT(Rect()));
connect(ui->rb_cylin, SIGNAL(clicked(bool)), this, SLOT(Cyl()));
connect(ui->sp_X, SIGNAL(valueChanged(int)), this, SLOT(x_Changed(int)));
connect(ui->sp_Y, SIGNAL(valueChanged(int)), this, SLOT(y_Changed(int)));
connect(ui->sp_Z, SIGNAL(valueChanged(int)), this, SLOT(z_Changed(int)));
/* Note: */
// Get the feature data
Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
// Fill data into dialog elements
ui->sp_X->setValue(pcConstraint->X_rot.getValue());
ui->sp_Y->setValue(pcConstraint->Y_rot.getValue());
ui->sp_Z->setValue(pcConstraint->Z_rot.getValue());
std::string transform_type = pcConstraint->TransformType.getValueAsString();
if (transform_type == "Rectangular") {
ui->sw_transform->setCurrentIndex(0);
ui->rb_rect->setChecked(1);
ui->rb_cylin->setChecked(0);
} else if (transform_type == "Cylindrical") {
ui->sw_transform->setCurrentIndex(1);
ui->rb_rect->setChecked(0);
ui->rb_cylin->setChecked(1);
}
/* */
ui->lw_Rect->clear();
//Transformable surfaces
Gui::Command::doCommand(Gui::Command::Doc,TaskFemConstraintTransform::getDisplcementReferences((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str());
std::vector<App::DocumentObject*> ObjDispl = pcConstraint->RefDispl.getValues();
std::vector<App::DocumentObject*> nDispl = pcConstraint->NameDispl.getValues();
std::vector<std::string> SubElemDispl = pcConstraint->RefDispl.getSubValues();
for (std::size_t i = 0; i < ObjDispl.size(); i++) {
ui->lw_displobj_rect->addItem(makeRefText(ObjDispl[i], SubElemDispl[i]));
ui->lw_displobj_cylin->addItem(makeRefText(ObjDispl[i], SubElemDispl[i]));
ui->lw_dis_rect->addItem(makeText(nDispl[i]));
ui->lw_dis_cylin->addItem(makeText(nDispl[i]));
}
if (Objects.size() > 0) {
for (std::size_t i = 0; i < Objects.size(); i++) {
ui->lw_Rect->addItem(makeRefText(Objects[i], SubElements[i]));
}
}
int p = 0;
for (std::size_t i = 0; i < ObjDispl.size(); i++) {
for (std::size_t j = 0; j < Objects.size(); j++) {
if ((makeRefText(ObjDispl[i], SubElemDispl[i]))==(makeRefText(Objects[j], SubElements[j]))){
p++;
}
}
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
updateUI();
if ((p==0) && (Objects.size() > 0)) {
QMessageBox::warning(this, tr("Constraint update error"), tr("The transformable faces have changed. Please add only the transformable faces and remove non-transformable faces!"));
return;
}
}