本文整理汇总了C++中MLayout::setContentsMargins方法的典型用法代码示例。如果您正苦于以下问题:C++ MLayout::setContentsMargins方法的具体用法?C++ MLayout::setContentsMargins怎么用?C++ MLayout::setContentsMargins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MLayout
的用法示例。
在下文中一共展示了MLayout::setContentsMargins方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testLayoutInLayoutRefresh
void Ut_MGridLayoutPolicy::testLayoutInLayoutRefresh()
{
m_policy->setSpacing(0);
m_mockLayout->activate();
QGraphicsWidget *widget = new QGraphicsWidget;
MLayout *layout = new MLayout(widget);
layout->setContentsMargins(0,0,0,0);
MGridLayoutPolicy *policy = new MGridLayoutPolicy(layout);
m_policy->addItem(widget,0,0);
QGraphicsWidget *leftSpacerWithWidget = new QGraphicsWidget;
policy->addItem(leftSpacerWithWidget, 0, 0);
policy->addItem(m_mockItem100, 0, 1);
policy->addItem(new QGraphicsWidget, 0, 2);
policy->addItem(m_mockItem200, 0, 3);
m_form->resize(400,200);
qApp->processEvents();
qApp->processEvents();
QCOMPARE(m_mockItem100->geometry(), QRectF(50,0,100,100));
QCOMPARE(m_mockItem200->geometry(), QRectF(200,0,200,200));
leftSpacerWithWidget->setMaximumWidth(0);
qApp->processEvents();
QCOMPARE(m_mockItem100->geometry(), QRectF(0,0,100,100));
QCOMPARE(m_mockItem200->geometry(), QRectF(200,0,200,200));
}
示例2: createContent
void ApplicationMenuPage::createContent()
{
MApplicationPage::createContent();
pannableViewport()->setAcceptGesturesFromAnyDirection(true);
setStyleName(inv("CommonApplicationPage"));
QGraphicsWidget *panel = centralWidget();
infoLabel = new MLabel(panel);
infoLabel->setObjectName("infoLabel");
infoLabel->setStyleName(inv("CommonBodyText"));
infoLabel->setWordWrap(true);
infoLabel->setAlignment(Qt::AlignTop);
actionItalic = new MAction(panel);
actionItalic->setObjectName("actionItalic");
actionItalic->setLocation(MAction::ApplicationMenuLocation);
addAction(actionItalic);
connect(actionItalic, SIGNAL(triggered()), this, SLOT(makeTextItalic()));
actionNormal = new MAction(panel);
actionNormal->setObjectName("actionNormal");
actionNormal->setLocation(MAction::ApplicationMenuLocation);
addAction(actionNormal);
connect(actionNormal, SIGNAL(triggered()), this, SLOT(makeTextNormal()));
MWidgetAction *widgetAction = new MWidgetAction(panel);
widgetAction->setLocation(MAction::ApplicationMenuLocation);
QStringList list;
for (int i = 0; i < 5; ++i) {
list << QString::number(100 + i);
}
comboBox = new MComboBox;
comboBox->setObjectName("comboBox");
comboBox->addItems(list);
comboBox->setIconVisible(false);
comboBox->setTitle("ComboBox");
comboBox->setCurrentIndex(0);
widgetAction->setWidget(comboBox);
addAction(widgetAction);
MLayout *layout = new MLayout(panel);
layout->setContentsMargins(0, 0, 0, 0);
panel->setLayout(layout);
policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
policy->setContentsMargins(0, 0, 0, 0);
policy->setSpacing(0);
policy->addItem(infoLabel);
retranslateUi();
}
示例3: initWidget
// ----------------------------------------------------------------------------
// CReporterPrivacySettingsWidget::initWidget
// ----------------------------------------------------------------------------
void CReporterPrivacySettingsWidget::initWidget()
{
//% "Crash Reporter"
MLabel *titleLabel = new MLabel(qtTrId("qtn_dcp_crash_reporter").arg(QString(CREPORTERVERSION)));
titleLabel->setStyleName("CommonApplicationHeaderInverted");
//% "Version %1"
MLabel *versionLabel = new MLabel(qtTrId("qtn_dcp_version_%1").arg(QString(CREPORTERVERSION)));
versionLabel->setStyleName("CommonSubTitleInverted");
// Create containers.
CReporterMonitorSettingsContainer *monitorSettings =
new CReporterMonitorSettingsContainer(this);
CReporterIncludeSettingsContainer *includeSettings =
new CReporterIncludeSettingsContainer(this);
// Button for showing privacy statement.
MButton *showPrivacyButton = new MButton(this);
showPrivacyButton->setObjectName("ShowPrivacyButton");
showPrivacyButton->setStyleName("CommonSingleButtonInverted");
//% "Privacy Disclaimer"
showPrivacyButton->setText(qtTrId("qtn_dcp_privacy_statement_button"));
connect(showPrivacyButton, SIGNAL(clicked()), this, SLOT(openPrivacyDisclaimerDialog()));
// Button for sending cores via selection
MButton *sendSelectButton = new MButton(this);
sendSelectButton->setObjectName("SendSelectButton");
sendSelectButton->setStyleName("CommonSingleButtonInverted");
//% "Send/Delete Reports"
sendSelectButton->setText(qtTrId("qtn_dcp_send_delete_button_text"));
connect(sendSelectButton, SIGNAL(clicked()), this, SLOT (handleSendSelectButtonClicked()), Qt::DirectConnection);
connect(sendSelectButton, SIGNAL(clicked()), monitorSettings, SLOT(updateButtons()), Qt::QueuedConnection);
// Create main layout and policy.
MLayout *mainLayout = new MLayout(this);
MLinearLayoutPolicy *mainLayoutPolicy =
new MLinearLayoutPolicy(mainLayout, Qt::Vertical);
mainLayoutPolicy->setObjectName("PageMainLayout");
mainLayout->setPolicy(mainLayoutPolicy);
mainLayout->setContentsMargins(0,0,0,0);
mainLayoutPolicy->addItem(titleLabel, Qt::AlignLeft);
mainLayoutPolicy->addItem(versionLabel, Qt::AlignLeft);
mainLayoutPolicy->addItem(monitorSettings, Qt::AlignCenter);
mainLayoutPolicy->addItem(includeSettings, Qt::AlignCenter);
// mainLayoutPolicy->addItem(bottomLayout, Qt::AlignCenter);
mainLayoutPolicy->addStretch();
mainLayoutPolicy->addItem(showPrivacyButton, Qt::AlignCenter);
mainLayoutPolicy->addItem(sendSelectButton, Qt::AlignCenter);
}
示例4: MLinearLayoutPolicy
void
WarrantyWidget::createContent ()
{
MLayout *layout;
MLinearLayoutPolicy *policy;
layout = new MLayout;
layout->setContentsMargins (0,0,0,0);
policy = new MLinearLayoutPolicy (layout, Qt::Vertical);
policy->setContentsMargins (0., 0., 0., 0.);
policy->setSpacing (0.);
/*
* Add the title-bar
*/
addHeaderContainer (policy);
#ifdef APP_TITLE_USES_SPACER
addStretcher (policy, APP_TITLE_DIVIDER_STYLE_NAME);
#endif
if (m_warrantyTimer) {
// The label that shows the expiration date
m_labelExpiration = new MLabel;
m_labelExpiration->setObjectName ("WarrantyAppletExpirationLabel");
m_labelExpiration->setStyleName ("CommonTitleInverted");
m_labelExpiration->setWordWrap (true);
}
// The label that shows the terms of the warranty
m_labelTerms = new MLabel;
m_labelTerms->setObjectName ("WarrantyAppletTermsLabel");
m_labelTerms->setStyleName ("CommonBodyTextInverted");
m_labelTerms->setWordWrap (true);
/*
* Adding the two labels with a new container
*/
addLabelContainer (policy, m_labelExpiration, m_labelTerms);
policy->addStretch ();
retranslateUi ();
layout->setPolicy (policy);
setLayout (layout);
}
示例5: createContent
void SheetsPage::createContent()
{
MApplicationPage::createContent();
QGraphicsWidget *panel = centralWidget();
MLayout *layout = new MLayout(panel);
layout->setContentsMargins(0, 0, 0, 0);
panel->setLayout(layout);
policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
policy->setContentsMargins(0, 0, 0, 0);
policy->setSpacing(0);
populateLayout();
retranslateUi();
}
示例6: testHeightForWidthInSubLayout
void Ut_MGridLayoutPolicy::testHeightForWidthInSubLayout()
{
QFETCH(bool, useMLayout);
QFETCH(bool, useInnerMLayout);
QFETCH(bool, putInnerWidgetInWidget);
QGraphicsWidget *form = new QGraphicsWidget;
MGridLayoutPolicy *mpolicy = NULL;
QGraphicsGridLayout *qlayout = NULL;
if (useMLayout) {
MLayout *mlayout = new MLayout(form);
mlayout->setContentsMargins(0, 0, 0, 0);
mpolicy = new MGridLayoutPolicy(mlayout);
mpolicy->setSpacing(0);
} else {
qlayout = new QGraphicsGridLayout(form);
qlayout->setContentsMargins(0, 0, 0, 0);
qlayout->setSpacing(0);
}
QGraphicsWidget *topSpacer = createSpacer();
QGraphicsWidget *leftSpacer = createSpacer();
QGraphicsWidget *rightSpacer = createSpacer();
leftSpacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
rightSpacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
QGraphicsWidget *square = new SquareWidget;
QGraphicsLayout *innerLayout = NULL;
if (useInnerMLayout) {
innerLayout = new MLayout();
MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(static_cast<MLayout *>(innerLayout), Qt::Horizontal);
policy->addItem(square);
} else {
innerLayout = new QGraphicsLinearLayout(Qt::Horizontal);
static_cast<QGraphicsLinearLayout *>(innerLayout)->addItem(square);
}
innerLayout->setContentsMargins(0,0,0,0);
QGraphicsLayoutItem *innerItem;
if (putInnerWidgetInWidget) {
QGraphicsWidget *innerWidget = new QGraphicsWidget;
innerWidget->setLayout(innerLayout);
innerItem = innerWidget;
} else {
innerItem = innerLayout;
}
if (useMLayout) {
mpolicy->addItem(topSpacer, 0, 1);
mpolicy->addItem(leftSpacer, 1, 0);
mpolicy->addItem(rightSpacer, 1, 2);
mpolicy->addItem(innerItem, 1, 1);
} else {
qlayout->addItem(topSpacer, 0, 1);
qlayout->addItem(leftSpacer, 1, 0);
qlayout->addItem(rightSpacer, 1, 2);
qlayout->addItem(innerItem, 1, 1);
}
QCOMPARE(form->preferredSize(), QSizeF(500,500));
QCOMPARE(form->effectiveSizeHint(Qt::PreferredSize, QSizeF(100,-1)), QSizeF(100,100));
delete form;
}
示例7: createContent
void ConversationPage::createContent()
{
MApplicationPage::createContent();
setContentsMargins(0, 0, 0, 0);
setPannable(true);
createActions();
//% "Mail"
setTitle(qtTrId("xx_page_title"));
MLayout *layout = new MLayout(centralWidget());
layout->setContentsMargins(0, 0, 0, 0);
layout->setAnimation(0);
m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
m_policy->setObjectName("VerticalPolicy");
m_policy->setContentsMargins(0, 0, 0, 0);
m_policy->setSpacing(0);
QMailMessage message(m_id);
//% "From"
QString body = qtTrId("xx_from") + ": " + message.from().address() + "\n";
QStringList addresses = QMailAddress::toStringList(message.to());
//% "To"
body.append(qtTrId("xx_to") + ": " + addresses.join("; ") + "\n");
addresses = QMailAddress::toStringList(message.cc());
if (addresses.size() > 0)
//% "Cc"
body.append(qtTrId("xx_cc" ) + ": " + addresses.join("; ") + "\n");
addresses = QMailAddress::toStringList(message.bcc());
if (addresses.size() > 0)
//% "Bcc"
body.append(qtTrId("xx_bcc" ) + ": " + addresses.join("; ") + "\n");
QMailAddress replyTo = message.replyTo();
if (!replyTo.isNull())
//% "Reply-To"
body.append(qtTrId("xx_reply_to") + ": " + replyTo.toString() + "\n");
//% "Subject"
body.append(qtTrId("xx_subject") + ": " + message.subject() + "\n");
//% "Date: %1"
body.append(qtTrId("xx_date").arg(message.date().toLocalTime().toString(Qt::SystemLocaleShortDate)));
MLabel *messageBody = new MLabel(body);
messageBody->setWordWrap(true);
messageBody->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
messageBody->setObjectName("BodyText");
m_policy->addItem(messageBody);
MSeparator *separator = new MSeparator();
separator->setObjectName("Separator");
m_policy->addItem(separator);
messageBody = new MLabel("\n" + Utils::bodyPlainText(&message));
messageBody->setWordWrap(true);
messageBody->setObjectName("BodyText");
messageBody->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_policy->addItem (messageBody);
processAttachments(message);
centralWidget()->setLayout(layout);
}
示例8: createcontent
// ----------------------------------------------------------------------------
// CReporterSendSelectedDialog::createcontent
// ----------------------------------------------------------------------------
void CReporterSendSelectedDialog::createcontent()
{
Q_D(CReporterSendSelectedDialog);
setObjectName("CrashReporterSendSelectedDialog");
int nbrOfFiles = d_ptr->files.count();
QString message;
if (nbrOfFiles == 1) {
//% "<p>This system has 1 stored crash report. Select reports to send to %1 for analysis or to delete.</p>"
message = qtTrId("qtn_system_has_1_crash_report_send_to_%s").arg(d->server);
}
else {
//% "<p>This system has %1 stored crash reports. Select reports to send to %2 for analysis or to delete.</p>"
message = qtTrId("qtn_system_has_%1_crash_reports_send_to_%2").arg(nbrOfFiles).arg(d->server);
}
// Create content to be placed on central widget.
QGraphicsWidget *panel = centralWidget();
// Create layout and policy.
MLayout *layout = new MLayout(panel);
layout->setContentsMargins(0,0,0,0);
panel->setLayout(layout);
MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
policy->setObjectName("DialogMainLayout");
// Create message label and hack it to support wordwrapping
MLabel *messagelabel = new MLabel(message, panel);
messagelabel->setWordWrap(true);
messagelabel->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
messagelabel->setObjectName("DialogMessageLabel");
messagelabel->setStyleName("CommonFieldLabelInverted");
d->list = new MList(panel);
d->cellCreator = new MContentItemCreator;
d->list->setCellCreator(d->cellCreator);
d->model = new CReporterSendFileListModel(d->files);
d->list->setItemModel(d->model);
d->list->setSelectionMode(MList::MultiSelection);
// Add widgets to the layout
policy->addItem(messagelabel, Qt::AlignLeft | Qt::AlignTop);
policy->addItem(d->list, Qt::AlignLeft | Qt::AlignTop);
// Add buttons to button area.
QSignalMapper *mapper = new QSignalMapper(this);
//% "Send Selected"
MButton* dialogButton = new MButton(qtTrId("qtn_send_selected_button"));
dialogButton->setStyleName("CommonSingleButtonInverted");
policy->addItem(dialogButton, Qt::AlignCenter);
// MButtonModel *dialogButton = addButton(qtTrId("qtn_send_selected_button"), M::ActionRole);
connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(dialogButton, static_cast<int>(CReporter::SendSelectedButton));
//% "Send All"
dialogButton = new MButton(qtTrId("qtn_send_all_button"));
dialogButton->setStyleName("CommonSingleButtonInverted");
policy->addItem(dialogButton, Qt::AlignCenter);
// dialogButton = addButton(qtTrId("qtn_send_all_button"), M::ActionRole);
connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(dialogButton, static_cast<int>(CReporter::SendAllButton));
//% "Delete Selected"
dialogButton = new MButton(qtTrId("qtn_delete_selected_button"));
dialogButton->setStyleName("CommonSingleButtonInverted");
policy->addItem(dialogButton, Qt::AlignCenter);
// dialogButton = addButton(qtTrId("qtn_delete_selected_button"), M::DestructiveRole);
connect(dialogButton, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(dialogButton, static_cast<int>(CReporter::DeleteSelectedButton));
connect(mapper, SIGNAL(mapped(int)), SIGNAL(actionPerformed(int)));
connect(mapper, SIGNAL(mapped(int)), SLOT(accept()));
}
示例9: MLayout
OpenDialog::OpenDialog(QGraphicsWidget*, const QString ¤tFileName)
{
MWidget *centralWidget = new MWidget;
MLayout *layout = new MLayout();
layout->setContentsMargins(0,0,0,0);
MLinearLayoutPolicy* landscapePolicy = new MLinearLayoutPolicy(layout, Qt::Vertical);
MLinearLayoutPolicy* portraitPolicy = new MLinearLayoutPolicy(layout, Qt::Vertical);
// m_itemSize.setWidth(100);
// m_itemSize.setHeight(100);
m_columnsPortrait = 4;
m_columnsLandscape = 5;
m_columnsLandscapeSlider = 0;
m_columnsPortraitSlider = 0;
list = new MList(this);
list->setObjectName("list");
landscapePolicy->addItem(list);
portraitPolicy->addItem(list);
landscapePolicy->setContentsMargins(20, 12, 20, 0);
portraitPolicy->setContentsMargins(20, 24, 20, 0);
layout->setLandscapePolicy(landscapePolicy);
layout->setPortraitPolicy(portraitPolicy);
//int initialWidth = MApplication::activeWindow()->visibleSceneSize().width();
/* if(MApplication::activeWindow()->orientation() == M::Portrait) {
list->setColumns(m_columnsPortrait);
m_itemSize.setWidth(initialWidth / m_columnsPortrait);
m_itemSize.setHeight(m_itemSize.width());
}
else {
list->setColumns(m_columnsLandscape);
m_itemSize.setWidth(initialWidth / m_columnsLandscape);
m_itemSize.setHeight(m_itemSize.width());
}*/
m_itemSize.setWidth(110);
m_itemSize.setHeight(110);
ContentItemCreator *cellCreator = new ContentItemCreator(this);
list->setCellCreator(cellCreator);
QStringList mediaDirs;
mediaDirs << APP_CATALOG;
model = new OpenDialogModel(this, m_itemSize.toSize(), mediaDirs, currentFileName);
model->setObjectName("gridModel");
list->setItemModel(model);
connect(list, SIGNAL(itemClicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex)));
connect(list, SIGNAL(panningStarted()), this, SLOT(pauseLoaders()));
connect(list, SIGNAL(panningStopped()), this, SLOT(resumeLoaders()));
centralWidget->setLayout(layout);
this->setTitle("Choose an image");
this->setModal(true);
this->setCentralWidget(centralWidget);
}