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


C++ QLayout::getContentsMargins方法代码示例

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


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

示例1: QWidget

UINetworkRequestWidget::UINetworkRequestWidget(UINetworkManagerDialog *pParent, UINetworkRequest *pNetworkRequest)
    : QIWithRetranslateUI<UIPopupBox>(pParent)
    , m_pContentWidget(new QWidget(this))
    , m_pMainLayout(new QGridLayout(m_pContentWidget))
    , m_pProgressBar(new QProgressBar(m_pContentWidget))
    , m_pRetryButton(new QIToolButton(m_pContentWidget))
    , m_pCancelButton(new QIToolButton(m_pContentWidget))
    , m_pErrorPane(new QIRichTextLabel(m_pContentWidget))
    , m_pNetworkRequest(pNetworkRequest)
    , m_pTimer(new QTimer(this))
{
    /* Setup self: */
    setTitleIcon(UIIconPool::iconSet(":/nw_16px.png"));
    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    setContentWidget(m_pContentWidget);
    setOpen(true);

    /* Prepare listeners for m_pNetworkRequest: */
    connect(m_pNetworkRequest, SIGNAL(sigProgress(qint64, qint64)), this, SLOT(sltSetProgress(qint64, qint64)));
    connect(m_pNetworkRequest, SIGNAL(sigStarted()), this, SLOT(sltSetProgressToStarted()));
    connect(m_pNetworkRequest, SIGNAL(sigFinished()), this, SLOT(sltSetProgressToFinished()));
    connect(m_pNetworkRequest, SIGNAL(sigFailed(const QString&)), this, SLOT(sltSetProgressToFailed(const QString&)));

    /* Setup timer: */
    m_pTimer->setInterval(5000);
    connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltTimeIsOut()));

    /* Setup main-layout: */
    m_pMainLayout->setContentsMargins(6, 6, 6, 6);

    /* Setup progress-bar: */
    m_pProgressBar->setRange(0, 0);
    m_pProgressBar->setMaximumHeight(16);

    /* Setup retry-button: */
    m_pRetryButton->setHidden(true);
    m_pRetryButton->removeBorder();
    m_pRetryButton->setFocusPolicy(Qt::NoFocus);
    m_pRetryButton->setIcon(UIIconPool::iconSet(":/refresh_16px.png"));
    connect(m_pRetryButton, SIGNAL(clicked(bool)), this, SIGNAL(sigRetry()));

    /* Setup cancel-button: */
    m_pCancelButton->removeBorder();
    m_pCancelButton->setFocusPolicy(Qt::NoFocus);
    m_pCancelButton->setIcon(UIIconPool::iconSet(":/delete_16px.png"));
    connect(m_pCancelButton, SIGNAL(clicked(bool)), this, SIGNAL(sigCancel()));

    /* Setup error-label: */
    m_pErrorPane->setHidden(true);
    m_pErrorPane->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    /* Calculate required width: */
    int iMinimumWidth = pParent->minimumWidth();
    int iLeft, iTop, iRight, iBottom;
    /* Take into account content-widget layout margins: */
    m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
    iMinimumWidth -= iLeft;
    iMinimumWidth -= iRight;
    /* Take into account this layout margins: */
    layout()->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
    iMinimumWidth -= iLeft;
    iMinimumWidth -= iRight;
    /* Take into account parent layout margins: */
    QLayout *pParentLayout = qobject_cast<QMainWindow*>(parent())->centralWidget()->layout();
    pParentLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
    iMinimumWidth -= iLeft;
    iMinimumWidth -= iRight;
    /* Set minimum text width: */
    m_pErrorPane->setMinimumTextWidth(iMinimumWidth);

    /* Layout content: */
    m_pMainLayout->addWidget(m_pProgressBar, 0, 0);
    m_pMainLayout->addWidget(m_pRetryButton, 0, 1);
    m_pMainLayout->addWidget(m_pCancelButton, 0, 2);
    m_pMainLayout->addWidget(m_pErrorPane, 1, 0, 1, 3);

    /* Retranslate UI: */
    retranslateUi();
}
开发者ID:mutoso-mirrors,项目名称:vbox,代码行数:78,代码来源:UINetworkRequestWidget.cpp


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