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


C++ QWidgetAction::defaultWidget方法代码示例

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


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

示例1: QMenu

EmoticonMenu::EmoticonMenu(QWidget *parent) :
    QMenu(parent)
{
    layout = new QGridLayout(this);
    layout->setContentsMargins(1,1,1,1);
    layout->setSpacing(0);

    QWidgetAction *action = new QWidgetAction(this);
    action->setDefaultWidget(new QWidget(this));
    action->defaultWidget()->setLayout(layout);
    this->addAction(action);

    // some Skype smileys
    addEmoticon(":/icons/emoticons/emotion_smile.png",    {":)", ":-)", ":o)"});
    addEmoticon(":/icons/emoticons/emotion_sad.png",      {":(", ":-("});
    addEmoticon(":/icons/emoticons/emotion_grin.png",     {":D", ":-D"});
    addEmoticon(":/icons/emoticons/emotion_cool.png",     {"8)", "8-)"});
    addEmoticon(":/icons/emoticons/emotion_suprised.png", {":O", ":-O"});
    addEmoticon(":/icons/emoticons/emotion_wink.png",     {";)", ";-)"});
    addEmoticon(":/icons/emoticons/emotion_cry.png",      {";(", ";-("});
    addEmoticon(":/icons/emoticons/emotion_sweat.png",    {"(:|"});
    // ...
    addEmoticon(":/icons/emoticons/emotion_kiss.png",     {":*", ":-*"});
    addEmoticon(":/icons/emoticons/emotion_tongue.png",   {":P", ":-P"});
    // ...
    addEmoticon(":/icons/emoticons/emotion_doubt.png",    {":^)", ":^-)"});
    // ...
    addEmoticon(":/icons/emoticons/emotion_love.png",     {"(inlove)"});
    addEmoticon(":/icons/emoticons/emotion_evilgrin.png", {"]:)", "]:-)"});
    // ...
    addEmoticon(":/icons/emoticons/emotion_angel.png",    {"O:)", "O:-)", "o:)", "o:-)", "(angel)"});
    // ...
}
开发者ID:lance0,项目名称:ProjectTox-Qt-GUI,代码行数:33,代码来源:emoticonmenu.cpp

示例2: setupUi


//.........这里部分代码省略.........
    connect(mpHistory, SIGNAL(aboutToPlay(QString)), SLOT(play(QString)));
    pWA = new QWidgetAction(0);
    pWA->setDefaultWidget(mpHistory);
    subMenu->addAction(pWA); //must add action after the widget action is ready. is it a Qt bug?

    mpMenu->addSeparator();

    //mpMenu->addAction(tr("Report"))->setEnabled(false); //report bug, suggestions etc. using maillist?
    mpMenu->addAction(tr("About"), this, SLOT(about()));
    mpMenu->addAction(tr("Help"), this, SLOT(help()));
    mpMenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()));
    mpMenu->addAction(tr("Donate"), this, SLOT(donate()));
    mpMenu->addAction(tr("Setup"), this, SLOT(setup()));
    mpMenu->addSeparator();
    mpMenuBtn->setMenu(mpMenu);
    mpMenu->addSeparator();

    subMenu = new QMenu(tr("Speed"));
    mpMenu->addMenu(subMenu);
    QDoubleSpinBox *pSpeedBox = new QDoubleSpinBox(0);
    pSpeedBox->setRange(0.01, 20);
    pSpeedBox->setValue(1.0);
    pSpeedBox->setSingleStep(0.01);
    pSpeedBox->setCorrectionMode(QAbstractSpinBox::CorrectToPreviousValue);
    pWA = new QWidgetAction(0);
    pWA->setDefaultWidget(pSpeedBox);
    subMenu->addAction(pWA); //must add action after the widget action is ready. is it a Qt bug?

    subMenu = new ClickableMenu(tr("Repeat"));
    mpMenu->addMenu(subMenu);
    //subMenu->setEnabled(false);
    mpRepeatEnableAction = subMenu->addAction(tr("Enable"));
    mpRepeatEnableAction->setCheckable(true);
    connect(mpRepeatEnableAction, SIGNAL(toggled(bool)), SLOT(toggleRepeat(bool)));
    // TODO: move to a func or class
    mpRepeatBox = new QSpinBox(0);
    mpRepeatBox->setMinimum(-1);
    mpRepeatBox->setValue(-1);
    mpRepeatBox->setToolTip("-1: " + tr("infinity"));
    connect(mpRepeatBox, SIGNAL(valueChanged(int)), SLOT(setRepeateMax(int)));
    QLabel *pRepeatLabel = new QLabel(tr("Times"));
    QHBoxLayout *hb = new QHBoxLayout;
    hb->addWidget(pRepeatLabel);
    hb->addWidget(mpRepeatBox);
    QVBoxLayout *vb = new QVBoxLayout;
    vb->addLayout(hb);
    pRepeatLabel = new QLabel(tr("From"));
    mpRepeatA = new QTimeEdit();
    mpRepeatA->setDisplayFormat("HH:mm:ss");
    mpRepeatA->setToolTip(tr("negative value means from the end"));
    connect(mpRepeatA, SIGNAL(timeChanged(QTime)), SLOT(repeatAChanged(QTime)));
    hb = new QHBoxLayout;
    hb->addWidget(pRepeatLabel);
    hb->addWidget(mpRepeatA);
    vb->addLayout(hb);
    pRepeatLabel = new QLabel(tr("To"));
    mpRepeatB = new QTimeEdit();
    mpRepeatB->setDisplayFormat("HH:mm:ss");
    mpRepeatB->setToolTip(tr("negative value means from the end"));
    connect(mpRepeatB, SIGNAL(timeChanged(QTime)), SLOT(repeatBChanged(QTime)));
    hb = new QHBoxLayout;
    hb->addWidget(pRepeatLabel);
    hb->addWidget(mpRepeatB);
    vb->addLayout(hb);
    QWidget *pRepeatWidget = new QWidget;
    pRepeatWidget->setLayout(vb);

    pWA = new QWidgetAction(0);
    pWA->setDefaultWidget(pRepeatWidget);
    pWA->defaultWidget()->setEnabled(false);
    subMenu->addAction(pWA); //must add action after the widget action is ready. is it a Qt bug?
    mpRepeatAction = pWA;

    mpMenu->addSeparator();

    subMenu = new ClickableMenu(tr("Subtitle"));
    mpMenu->addMenu(subMenu);
    QAction *act = subMenu->addAction(tr("Enable"));
    act->setCheckable(true);
    act->setChecked(mpSubtitle->isEnabled());
    connect(act, SIGNAL(toggled(bool)), SLOT(toggoleSubtitleEnabled(bool)));
    act = subMenu->addAction(tr("Auto load"));
    act->setCheckable(true);
    act->setChecked(mpSubtitle->autoLoad());
    connect(act, SIGNAL(toggled(bool)), SLOT(toggleSubtitleAutoLoad(bool)));
    subMenu->addAction(tr("Open"), this, SLOT(openSubtitle()));
    QWidget *csWidget = new QWidget();
    hb = new QHBoxLayout();
    csWidget->setLayout(hb);
    hb->addWidget(new QLabel(tr("Charset")));
    QComboBox *csBox = new QComboBox();
    hb->addWidget(csBox);
    pWA = new QWidgetAction(0);
    pWA->setDefaultWidget(csWidget);
    subMenu->addAction(pWA); //must add action after the widget action is ready. is it a Qt bug?
    csBox->addItem(tr("Auto detect"), "AutoDetect");
    csBox->addItem(tr("System"), "System");
    foreach (QByteArray cs, QTextCodec::availableCodecs()) {
        csBox->addItem(cs, cs);
    }
开发者ID:iHaD,项目名称:QtAV,代码行数:101,代码来源:MainWindow.cpp


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