本文整理汇总了C++中MLayout::setPortraitPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ MLayout::setPortraitPolicy方法的具体用法?C++ MLayout::setPortraitPolicy怎么用?C++ MLayout::setPortraitPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MLayout
的用法示例。
在下文中一共展示了MLayout::setPortraitPolicy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
MApplication app(argc, argv);
MTheme::loadCSS("layout_inside_layout.css");
MApplicationWindow window;
MApplicationPage page;
/* Create a MLayout that we set the policies for */
MLayout *layout = new MLayout;
MLinearLayoutPolicy *portraitPolicy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
MLinearLayoutPolicy *landscapePolicy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
for (int i = 0; i < 3; ++i) {
MLabel *label = new MLabel(QString("Item %1").arg(i + 1));
label->setAlignment(Qt::AlignCenter);
label->setObjectName("item"); //Set CSS name for styling
portraitPolicy->addItem(label);
landscapePolicy->addItem(label);
}
/* Create a widget to hold the inner layout and to put inside the policy */
QGraphicsWidget *widget = new QGraphicsWidget;
/* Create an inner layout. A QGraphicsGridLayout is used since we don't require
* multiple policies here, but using a MLayout would also work. */
QGraphicsGridLayout *innerLayout = new QGraphicsGridLayout(widget);
for (int i = 0; i < 4; ++i) {
MLabel *label = new MLabel(QString("Inner Item %1").arg(i + 1));
label->setAlignment(Qt::AlignCenter);
label->setObjectName("inneritem"); //Set CSS name for styling
innerLayout->addItem(label, i / 2, i % 2);
}
/* Now add the widget to the landscape policy only, so that the innerLayout is hidden when device is rotated */
landscapePolicy->addItem(widget);
layout->setLandscapePolicy(landscapePolicy);
layout->setPortraitPolicy(portraitPolicy);
/* Attach the layout to the page */
page.centralWidget()->setLayout(layout);
page.appear(&window);
window.show();
return app.exec();
}
示例2: createContent
void AlbumPage::createContent()
{
MLayout *layout = new MLayout;
centralWidget()->setLayout(layout);
// Build a vertical layout that holds the cover art and the "By: Artist" label.
QGraphicsLinearLayout *coverAndArtistLayout = new QGraphicsLinearLayout(Qt::Vertical);
MImageWidget *albumCover = new MImageWidget(new QImage(album->coverArtFilename));
coverAndArtistLayout->addItem(albumCover);
QString byArtist = QString("By: %1").arg(album->artist);
coverAndArtistLayout->addItem(new MLabel(byArtist));
// Build a vertical layout that will hold the list of songs.
QGraphicsLinearLayout *songsLayout = new QGraphicsLinearLayout(Qt::Vertical);
songsLayout->addItem(new MLabel("Songs:"));
MLabel *songLabel;
for (int i = 0; i < album->songs.count(); i++) {
songLabel = new MLabel(album->songs.at(i));
songsLayout->addItem(songLabel);
}
// When in landscape orientation, have the cover and the songs list
// side-by-side.
MLinearLayoutPolicy *landscapePolicy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
landscapePolicy->addItem(coverAndArtistLayout);
landscapePolicy->addItem(songsLayout);
layout->setLandscapePolicy(landscapePolicy);
// When in portrait orientation, have the cover and the songs list
// on top of each other.
MLinearLayoutPolicy *portraitPolicy = new MLinearLayoutPolicy(layout, Qt::Vertical);
portraitPolicy->addItem(coverAndArtistLayout);
portraitPolicy->addItem(songsLayout);
layout->setPortraitPolicy(portraitPolicy);
}
示例3: controller
MColorListViewPrivate::MColorListViewPrivate(MColorListView *p, MColorList *controller)
: q_ptr(p), controller(controller), landscapePolicy(0), portraitPolicy(0), buttonGroup(0)
{
QGraphicsGridLayout *layout = new QGraphicsGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
controller->setLayout(layout);
MStylableWidget* container = new MStylableWidget();
container->setStyleName("ColorSelectionContainer");
MLayout *containerLayout = new MLayout();
container->setLayout(containerLayout);
landscapePolicy = new MGridLayoutPolicy(containerLayout);
landscapePolicy->setContentsMargins(0, 0, 0, 0);
landscapePolicy->setSpacing(0);
containerLayout->setLandscapePolicy(landscapePolicy);
portraitPolicy = new MGridLayoutPolicy(containerLayout);
portraitPolicy->setContentsMargins(0, 0, 0, 0);
portraitPolicy->setSpacing(0);
containerLayout->setPortraitPolicy(portraitPolicy);
layout->addItem(container, 0, 0);
// Current color list
colors << QColor(0x95, 0xE8, 0x5D);
colors << QColor(0x73, 0xC0, 0xF5);
colors << QColor(0xCB, 0xA4, 0xDE);
colors << QColor(0xE9, 0x48, 0xA3);
colors << QColor(0xFF, 0x9E, 0x9E);
colors << QColor(0xFF, 0xF6, 0x57);
colors << QColor(0x9C, 0x9C, 0x9C);
colors << QColor(0x74, 0xD9, 0x41);
colors << QColor(0x31, 0xB0, 0xDE);
colors << QColor(0xBC, 0x79, 0xDE);
colors << QColor(0xE9, 0x48, 0xA3);
colors << QColor(0xFF, 0x79, 0x4D);
colors << QColor(0xFB, 0xFF, 0x14);
colors << QColor(0x80, 0x80, 0x80);
colors << QColor(0x55, 0xD5, 0x00);
colors << QColor(0x00, 0x88, 0xE6);
colors << QColor(0xAE, 0x4E, 0xDE);
colors << QColor(0xE9, 0x48, 0xA3);
colors << QColor(0xFF, 0x40, 0x00);
colors << QColor(0xFF, 0xE6, 0x00);
colors << QColor(0x4D, 0x4D, 0x4D);
colors << QColor(0x45, 0x90, 0x27);
colors << QColor(0x00, 0x6F, 0xBA);
colors << QColor(0x89, 0x3D, 0xAF);
colors << QColor(0xE9, 0x48, 0xA3);
colors << QColor(0xCC, 0x33, 0x00);
colors << QColor(0xFF, 0x90, 0x00);
colors << QColor(0x33, 0x33, 0x33);
colors << QColor(0x00, 0x73, 0x00);
colors << QColor(0x00, 0x41, 0x82);
colors << QColor(0x5E, 0x2A, 0x78);
colors << QColor(0xE9, 0x48, 0xA3);
colors << QColor(0xB5, 0x2D, 0x00);
colors << QColor(0xFF, 0x6A, 0x00);
colors << QColor(0x1A, 0x1A, 0x1A);
}
示例4: createContent
void ArtistPage::createContent()
{
MApplicationPage::createContent();
QGraphicsWidget *panel = centralWidget();
MLayout* layout = new MLayout(panel);
m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
layout->setAnimation(NULL);
panel->setLayout(layout);
layout->setLandscapePolicy(m_policy);
layout->setPortraitPolicy(m_policy);
if (m_pageMode == ALL_ARTISTS) {
// Menu Actions
MAction* actionImportLastfm = new MAction(panel);
actionImportLastfm->setText(tr("Import from Last.fm"));
actionImportLastfm->setLocation(MAction::ApplicationMenuLocation);
addAction(actionImportLastfm);
connect(actionImportLastfm, SIGNAL(triggered()), this, SLOT(slotImportLastfm()));
MAction* actionAddArtist = new MAction(panel);
actionAddArtist->setText(tr("Add artist"));
actionAddArtist->setLocation(MAction::ApplicationMenuLocation);
addAction(actionAddArtist);
connect(actionAddArtist, SIGNAL(triggered()), this, SLOT(slotAddArtist()));
// Toolbar Actions
MAction* actionFilter = new MAction("icon-m-toolbar-filter", "", this);
actionFilter->setLocation(MAction::ToolBarLocation);
addAction(actionFilter);
connect(actionFilter, SIGNAL(triggered()), this, SLOT(slotShowFilter()));
}
MAction* actionRefresh = new MAction("icon-m-toolbar-refresh", "", this);
actionRefresh->setLocation(MAction::ToolBarLocation);
addAction(actionRefresh);
connect(actionRefresh, SIGNAL(triggered()), this, SLOT(slotRefreshEvents()));
MAction* actionSearch = new MAction("icon-m-toolbar-search", "", this);
actionSearch->setLocation(MAction::ToolBarLocation);
addAction(actionSearch);
connect(actionSearch, SIGNAL(triggered()), this, SLOT(slotShowSearch()));
// setup model
m_artistsModel = new ArtistModel(m_dbStorage, artistsModelQuery());
// filtering text box
QGraphicsLinearLayout *containerLayout = new QGraphicsLinearLayout(Qt::Horizontal);
MLabel* filterLabel = new MLabel(tr("Filter artist:"));
containerLayout->addItem(filterLabel);
m_filter = new MTextEdit(MTextEditModel::SingleLine, QString());
containerLayout->addItem(m_filter);
m_filter->setObjectName("CommonSingleInputField");
connect(m_filter, SIGNAL(textChanged()), this, SLOT(slotFilterChanged()));
m_filterWidget = new MWidget();
m_filterWidget->setLayout(containerLayout);
// No artist found label
m_noArtistLabel = new MLabel(tr("No artist available, add them using one of "
"menu options."));
m_noArtistLabel->setAlignment(Qt::AlignCenter);
if (m_artistsModel->rowCount() == 0)
m_policy->addItem(m_noArtistLabel);
// MList with fast view
MList* artistsList = new MList();
artistsList->setSelectionMode(MList::SingleSelection);
// Content item creator and item model for the list
artistsList->setCellCreator(new ArtistItemCreator(m_pageMode, m_dbStorage,
m_country));
artistsList->setItemModel(m_artistsModel);
m_policy->addItem(artistsList);
connect(artistsList, SIGNAL(itemClicked(QModelIndex)),
this, SLOT(slotArtistClicked(QModelIndex)));
connect(DBManager::instance(m_dbStorage), SIGNAL(artistAdded(int,bool)),
this, SLOT(slotArtistAdded(int,bool)));
if (m_pageMode == ARTIST_NEAR_LOCATION_SEARCH) {
//overwrite history
MApplicationWindow* appWindow = applicationWindow();
MScene* scene = appWindow->scene();
MSceneManager* sceneManager = scene->sceneManager();
QList<MSceneWindow*> history = sceneManager->pageHistory();
if (history.last()->metaObject()->className() == NearLocationSearchPage::staticMetaObject.className()) {
// overwrite history only if the last page is NearLocationSearchPage
history.removeAt(history.size()-1);
if (history.last()->metaObject()->className() != NearLocationMainPage::staticMetaObject.className()) {
MApplicationPage* prevPage = new NearLocationMainPage();
history << prevPage;
}
sceneManager->setPageHistory(history);
}
//search events
m_lastfm->getEventsNearLocation(m_latitude, m_longitude, m_distance);
//.........这里部分代码省略.........
示例5: setLayoutDirection
CalculatorWidget::CalculatorWidget()
{
mValue = 0;
//Prevent the layout from changing in right-to-left.
//The calculation line will still be reversed however.
setLayoutDirection(Qt::LeftToRight);
/* Create a MLayout attached to this widget */
MLayout *layout = new MLayout(this);
MGridLayoutPolicy *landscapePolicy = new MGridLayoutPolicy(layout);
MGridLayoutPolicy *portraitPolicy = new MGridLayoutPolicy(layout);
layout->setPortraitPolicy(portraitPolicy);
layout->setLandscapePolicy(landscapePolicy);
landscapePolicy->setObjectName("calculatorLandscape");
portraitPolicy->setObjectName("calculatorPortrait");
mCalculationLine = new MLabel;
mCalculationLine->setObjectName("calculationLine");
mCalculationLine->setAlignment(Qt::AlignRight);
QList<CalculatorButton *> buttons;
CalculatorButton *button;
for (int i = 0; i < 10; i++) {
button = new CalculatorButton(CalculatorButton::Button((int)CalculatorButton::Num0 + i), this);
if (i == 0) {
landscapePolicy->addItem(button, 3, 4);
portraitPolicy->addItem(button, 6, 0);
} else {
landscapePolicy->addItem(button, 2 - (i - 1) / 3, 4 + (i - 1) % 3);
portraitPolicy->addItem(button, 5 - (i - 1) / 3, (i - 1) % 3);
}
}
CalculatorButton *buttonC = new CalculatorButton(CalculatorButton::Clear, this);
CalculatorButton *buttonBackspace = new CalculatorButton(CalculatorButton::Backspace, this);
CalculatorButton *buttonSign = new CalculatorButton(CalculatorButton::Sign, this);
CalculatorButton *buttonDecimal = new CalculatorButton(CalculatorButton::Decimal, this);
CalculatorButton *buttonReciprocal = new CalculatorButton(CalculatorButton::Reciprocal, this);
CalculatorButton *buttonPower = new CalculatorButton(CalculatorButton::Power, this);
CalculatorButton *buttonSqrt = new CalculatorButton(CalculatorButton::Sqrt, this);
CalculatorButton *buttonPercentage = new CalculatorButton(CalculatorButton::Percentage, this);
CalculatorButton *buttonDivide = new CalculatorButton(CalculatorButton::Divide, this);
CalculatorButton *buttonMultiply = new CalculatorButton(CalculatorButton::Multiply, this);
CalculatorButton *buttonSubtract = new CalculatorButton(CalculatorButton::Subtract, this);
CalculatorButton *buttonAdd = new CalculatorButton(CalculatorButton::Add, this);
CalculatorButton *buttonEquals = new CalculatorButton(CalculatorButton::Equals, this);
buttonEquals->setObjectName("calculatorButtonEquals");
landscapePolicy->addItem(mCalculationLine, 0, 0, 1, 4);
landscapePolicy->addItem(buttonC, 1, 0);
landscapePolicy->addItem(buttonBackspace, 1, 1);
landscapePolicy->addItem(buttonSign, 1, 2);
landscapePolicy->addItem(buttonDecimal, 1, 3);
landscapePolicy->addItem(buttonReciprocal, 2, 0);
landscapePolicy->addItem(buttonPower, 2, 1);
landscapePolicy->addItem(buttonSqrt, 2, 2);
landscapePolicy->addItem(buttonPercentage, 2, 3);
landscapePolicy->addItem(buttonDivide, 3, 0);
landscapePolicy->addItem(buttonMultiply, 3, 1);
landscapePolicy->addItem(buttonSubtract, 3, 2);
landscapePolicy->addItem(buttonAdd, 3, 3);
landscapePolicy->addItem(buttonEquals, 3, 5, 1, 2);
portraitPolicy->addItem(mCalculationLine, 0, 0, 1, 4);
portraitPolicy->addItem(buttonC, 1, 0);
portraitPolicy->addItem(buttonBackspace, 1, 1);
portraitPolicy->addItem(buttonReciprocal, 1, 2);
portraitPolicy->addItem(buttonDivide, 1, 3);
portraitPolicy->addItem(buttonPower, 2, 0);
portraitPolicy->addItem(buttonSqrt, 2, 1);
portraitPolicy->addItem(buttonPercentage, 2, 2);
portraitPolicy->addItem(buttonMultiply, 2, 3);
portraitPolicy->addItem(buttonSubtract, 3, 3);
portraitPolicy->addItem(buttonAdd, 4, 3);
portraitPolicy->addItem(buttonEquals, 5, 3, 2, 1);
portraitPolicy->addItem(buttonDecimal, 6, 1);
portraitPolicy->addItem(buttonSign, 6, 2);
setValue(mValue);
}
示例6: 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);
}