本文整理汇总了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();
}