本文整理汇总了C++中QLayout::setAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayout::setAlignment方法的具体用法?C++ QLayout::setAlignment怎么用?C++ QLayout::setAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayout
的用法示例。
在下文中一共展示了QLayout::setAlignment方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void WWidgetGroup::setup(QDomNode node) {
setContentsMargins(0, 0, 0, 0);
// Set background pixmap if available
if (!WWidget::selectNode(node, "BackPath").isNull()) {
setPixmapBackground(WWidget::getPath(WWidget::selectNodeQString(node, "BackPath")));
}
QLayout* pLayout = NULL;
if (!XmlParse::selectNode(node, "Layout").isNull()) {
QString layout = XmlParse::selectNodeQString(node, "Layout");
if (layout == "vertical") {
pLayout = new QVBoxLayout();
pLayout->setSpacing(0);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setAlignment(Qt::AlignCenter);
} else if (layout == "horizontal") {
pLayout = new QHBoxLayout();
pLayout->setSpacing(0);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setAlignment(Qt::AlignCenter);
}
}
if (pLayout) {
setLayout(pLayout);
}
}
示例2: attach
void TextCheckbox::attach(QBoxLayout* layout) {
QLayout* lay = new QHBoxLayout;
lay->setAlignment(Qt::AlignLeft);
lay->addWidget(this);
lay->addWidget(mLabel);
layout->addLayout(lay);
}
开发者ID:tusharuiit,项目名称:2014-2015_MastersThesisPressureTemplatesForSmokeSimulationIn3D,代码行数:7,代码来源:customctrl.cpp
示例3: QToolBar
ToolBarImp::ToolBarImp(const string& id, const string& name, QWidget* parent) :
QToolBar(QString::fromStdString(name), parent),
WindowImp(id, name),
mpMenuBar(new MenuBarImp(QString::fromStdString(name), this)),
mMinToolBarWidth(0)
{
mpShowAction = new QAction("&Show", this);
mpShowAction->setAutoRepeat(false);
mpShowAction->setStatusTip("Shows the window");
mpHideAction = new QAction("&Hide", this);
mpHideAction->setAutoRepeat(false);
mpHideAction->setStatusTip("Hides the window");
// Initialization
setIconSize(QSize(16, 16));
addWidget(mpMenuBar);
setContextMenuPolicy(Qt::DefaultContextMenu);
setWindowOpacity(ToolBar::getSettingOpacity() / 100.0);
VERIFYNR(connect(mpShowAction, SIGNAL(triggered()), this, SLOT(show())));
VERIFYNR(connect(mpHideAction, SIGNAL(triggered()), this, SLOT(hide())));
VERIFYNR(connect(this, SIGNAL(topLevelChanged(bool)), this, SLOT(floatToolBar(bool))));
Service<ConfigurationSettings> pSettings;
pSettings->attach(SIGNAL_NAME(ConfigurationSettings, SettingModified),
Slot(this, &ToolBarImp::optionsModified));
// Prevent the menu bar from stretching
QLayout* pLayout = layout();
if (pLayout != NULL)
{
pLayout->setAlignment(mpMenuBar, Qt::AlignLeft | Qt::AlignVCenter);
}
}
示例4: creerBoutons
QWidget* QPageResultat::creerBoutons() {
QWidget * boutons = new QWidget(this);
QLayout * layout = new QHBoxLayout(boutons);
layout->setAlignment(Qt::AlignCenter);
boutons->setLayout(layout);
// Affiche le bouton "Voir ma performance"
boutonPerformance = new QPushButton("Voir ma performance",this);
//boutonPerformance->setMaximumSize(30,20);
layout->addWidget(boutonPerformance);
connect(boutonPerformance, SIGNAL(pressed()),
this, SLOT(afficherPerformance()));
// Affiche le bouton "Réessayer"
boutonReessayer = new QPushButton("Réssayer",this);
//boutonPerformance->setMaximumSize(30,20);
layout->addWidget(boutonReessayer);
// Affiche le bouton "Accueil"
boutonAccueil = new QPushButton("Accueil",this);
//boutonPerformance->setMaximumSize(30,20);
layout->addWidget(boutonAccueil);
return boutons;
}
示例5: creerScore
QWidget* QPageResultat::creerScore() {
QWidget * widget = new QWidget();
QLayout * layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignCenter);
widget->setLayout(layout);
// Définition du texte à afficher
int nbNotesReussis = 0;
for(int i = 0 ; i < partition.size() ; i++) {
if(partition[i].reussi) {
++nbNotesReussis;
}
}
QString texte = QString::number(nbNotesReussis);
texte.append(" sur ");
texte.append(QString::number(partition.size()));
texte.append(" notes trouvées !");
score = new QLabel(texte);
layout->addWidget(score);
// Definition de la police : Calibri, 14pt
QFont police = QFont();
police.setFamily("Calibri");
police.setPointSize(14);
score->setFont(police);
return widget;
}
示例6: QToolBar
ToolBarImp::ToolBarImp(const string& id, const string& name, QWidget* parent) :
QToolBar(QString::fromStdString(name), parent),
WindowImp(id, name),
mpMenuBar(new MenuBarImp(QString::fromStdString(name), this))
{
mpShowAction = new QAction("&Show", this);
mpShowAction->setAutoRepeat(false);
mpShowAction->setStatusTip("Shows the window");
mpHideAction = new QAction("&Hide", this);
mpHideAction->setAutoRepeat(false);
mpHideAction->setStatusTip("Hides the window");
// Initialization
setIconSize(QSize(16, 16));
addWidget(mpMenuBar);
setContextMenuPolicy(Qt::DefaultContextMenu);
VERIFYNR(connect(mpShowAction, SIGNAL(triggered()), this, SLOT(show())));
VERIFYNR(connect(mpHideAction, SIGNAL(triggered()), this, SLOT(hide())));
// Prevent the menu bar from stretching
QLayout* pLayout = layout();
if (pLayout != NULL)
{
pLayout->setAlignment(mpMenuBar, Qt::AlignLeft | Qt::AlignVCenter);
}
}
示例7: QwtLegend
//---------------------------------------------------------------------------
PlotLegend::PlotLegend( QWidget *parent ):
QwtLegend( parent )
{
setMinimumHeight( 1 );
setMaxColumns( 1 );
setContentsMargins( 0, 0, 0, 0 );
QLayout* layout = contentsWidget()->layout();
layout->setAlignment( Qt::AlignLeft | Qt::AlignTop );
layout->setSpacing( 0 );
QScrollArea *scrollArea = findChild<QScrollArea *>();
if ( scrollArea )
{
scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
}
#if 1
QFont fnt = font();
if ( fnt.pointSize() > 8 )
{
fnt.setPointSize( 8 );
setFont( fnt );
}
#endif
}
示例8: setLayoutAlignment
void WWidgetGroup::setLayoutAlignment(int alignment) {
//qDebug() << "WWidgetGroup::setLayoutAlignment" << alignment;
QLayout* pLayout = layout();
if (pLayout) {
pLayout->setAlignment(static_cast<Qt::Alignment>(alignment));
}
}
示例9: setup
void WWidgetGroup::setup(QDomNode node, const SkinContext& context) {
setContentsMargins(0, 0, 0, 0);
// Set background pixmap if available
if (context.hasNode(node, "BackPath")) {
setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")));
}
QLayout* pLayout = NULL;
if (context.hasNode(node, "Layout")) {
QString layout = context.selectString(node, "Layout");
if (layout == "vertical") {
pLayout = new QVBoxLayout();
pLayout->setSpacing(0);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setAlignment(Qt::AlignCenter);
} else if (layout == "horizontal") {
pLayout = new QHBoxLayout();
pLayout->setSpacing(0);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setAlignment(Qt::AlignCenter);
}
}
if (pLayout && context.hasNode(node, "SizeConstraint")) {
QMap<QString, QLayout::SizeConstraint> constraints;
constraints["SetDefaultConstraint"] = QLayout::SetDefaultConstraint;
constraints["SetFixedSize"] = QLayout::SetFixedSize;
constraints["SetMinimumSize"] = QLayout::SetMinimumSize;
constraints["SetMaximumSize"] = QLayout::SetMaximumSize;
constraints["SetMinAndMaxSize"] = QLayout::SetMinAndMaxSize;
constraints["SetNoConstraint"] = QLayout::SetNoConstraint;
QString sizeConstraintStr = context.selectString(node, "SizeConstraint");
if (constraints.contains(sizeConstraintStr)) {
pLayout->setSizeConstraint(constraints[sizeConstraintStr]);
} else {
qDebug() << "Could not parse SizeConstraint:" << sizeConstraintStr;
}
}
if (pLayout) {
setLayout(pLayout);
}
}
示例10: L
/*!
\internal
*/
QLayout *QFormBuilder::createLayout(const QString &layoutName, QObject *parent, const QString &name)
{
QLayout *l = 0;
QWidget *parentWidget = qobject_cast<QWidget*>(parent);
QLayout *parentLayout = qobject_cast<QLayout*>(parent);
Q_ASSERT(parentWidget || parentLayout);
#define DECLARE_WIDGET(W, C)
#define DECLARE_COMPAT_WIDGET(W, C)
#define DECLARE_LAYOUT(L, C) \
if (layoutName == QLatin1String(#L)) { \
Q_ASSERT(l == 0); \
l = parentLayout \
? new L() \
: new L(parentWidget); \
}
#include "widgets.table"
#undef DECLARE_LAYOUT
#undef DECLARE_COMPAT_WIDGET
#undef DECLARE_WIDGET
if (l) {
l->setObjectName(name);
if (parentLayout) {
QWidget *w = qobject_cast<QWidget *>(parentLayout->parent());
if (w && w->inherits("Q3GroupBox")) {
l->setContentsMargins(w->style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
w->style()->pixelMetric(QStyle::PM_LayoutTopMargin),
w->style()->pixelMetric(QStyle::PM_LayoutRightMargin),
w->style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
QGridLayout *grid = qobject_cast<QGridLayout *>(l);
if (grid) {
grid->setHorizontalSpacing(-1);
grid->setVerticalSpacing(-1);
} else {
l->setSpacing(-1);
}
l->setAlignment(Qt::AlignTop);
}
}
} else {
qWarning() << QCoreApplication::translate("QFormBuilder", "The layout type `%1' is not supported.").arg(layoutName);
}
return l;
}
示例11: creerAppreciation
QWidget* QPageResultat::creerAppreciation() {
QWidget * widget = new QWidget();
QLayout * layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignCenter);
widget->setLayout(layout);
QLabel * appreciation = new QLabel("Fini ! ");
layout->addWidget(appreciation);
// Definition de la police : Calibri, 18pt
QFont police = QFont();
police.setFamily("Calibri");
police.setPointSize(18);
appreciation->setFont(police);
return widget;
}
示例12: FlowLayoutContainer
QPointer<QWidget> QuMCQ::makeWidget(Questionnaire* questionnaire)
{
// Clear old stuff (BEWARE: "empty()" = "isEmpty()" != "clear()")
m_widgets.clear();
// Randomize?
if (m_randomize) {
m_options.shuffle();
}
bool read_only = questionnaire->readOnly();
// Actual MCQ: widget containing {widget +/- label} for each option
QPointer<QWidget> mainwidget;
QLayout* mainlayout;
if (m_horizontal) {
mainwidget = new FlowLayoutContainer();
mainlayout = new FlowLayout();
} else {
mainwidget = new QWidget();
mainwidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
mainlayout = new QVBoxLayout();
}
mainlayout->setContentsMargins(UiConst::NO_MARGINS);
mainwidget->setLayout(mainlayout);
// QGridLayout, but not QVBoxLayout or QHBoxLayout, can use addChildLayout;
// the latter use addWidget.
// FlowLayout is better than QHBoxLayout.
for (int i = 0; i < m_options.size(); ++i) {
const NameValuePair& nvp = m_options.at(i);
// MCQ touch-me widget
QPointer<BooleanWidget> w = new BooleanWidget();
w->setReadOnly(read_only);
w->setAppearance(m_as_text_button ? BooleanWidget::Appearance::Text
: BooleanWidget::Appearance::Radio);
if (m_as_text_button) {
w->setText(nvp.name());
}
if (!read_only) {
connect(w, &BooleanWidget::clicked,
std::bind(&QuMCQ::clicked, this, i));
}
m_widgets.append(w);
if (m_as_text_button) {
mainlayout->addWidget(w);
mainlayout->setAlignment(w, Qt::AlignTop);
} else {
// MCQ option label
// Even in a horizontal layout, encapsulating widget/label pairs
// prevents them being split apart.
QWidget* itemwidget = new QWidget();
ClickableLabelWordWrapWide* namelabel = new ClickableLabelWordWrapWide(nvp.name());
if (!read_only) {
connect(namelabel, &ClickableLabelWordWrapWide::clicked,
std::bind(&QuMCQ::clicked, this, i));
}
QHBoxLayout* itemlayout = new QHBoxLayout();
itemlayout->setContentsMargins(UiConst::NO_MARGINS);
itemwidget->setLayout(itemlayout);
itemlayout->addWidget(w);
itemlayout->addWidget(namelabel);
itemlayout->setAlignment(w, Qt::AlignTop);
itemlayout->setAlignment(namelabel, Qt::AlignVCenter); // different
itemlayout->addStretch();
mainlayout->addWidget(itemwidget);
mainlayout->setAlignment(itemwidget, Qt::AlignTop);
}
// The FlowLayout seems to ignore vertical centring. This makes it look
// slightly dumb when one label has much longer text than the others,
// but overall this is the best compromise I've found.
}
QPointer<QWidget> final_widget;
if (m_show_instruction) {
// Higher-level widget containing {instructions, actual MCQ}
QVBoxLayout* layout_w_instr = new QVBoxLayout();
layout_w_instr->setContentsMargins(UiConst::NO_MARGINS);
LabelWordWrapWide* instructions = new LabelWordWrapWide(
tr("Pick one:"));
instructions->setObjectName("mcq_instruction");
layout_w_instr->addWidget(instructions);
layout_w_instr->addWidget(mainwidget);
QPointer<QWidget> widget_w_instr = new QWidget();
widget_w_instr->setLayout(layout_w_instr);
widget_w_instr->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
final_widget = widget_w_instr;
} else {
final_widget = mainwidget;
}
setFromField();
return final_widget;
}
示例13: QWidget
AboutView::AboutView(QWidget *parent) : QWidget(parent) {
QBoxLayout *hLayout = new QHBoxLayout(this);
hLayout->setAlignment(Qt::AlignCenter);
hLayout->setMargin(30);
hLayout->setSpacing(30);
QLabel *logo = new QLabel(this);
logo->setPixmap(QPixmap(":/images/app.png"));
hLayout->addWidget(logo, 0, Qt::AlignTop);
QBoxLayout *layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignCenter);
layout->setSpacing(30);
hLayout->addLayout(layout);
QString info = "<html><style>a { color: palette(text); text-decoration: none; font-weight: bold }</style><body>"
"<h1 style='font-weight:normal'>" + QString(Constants::NAME) + "</h1>"
"<p>" + tr("There's life outside the browser!") + "</p>"
"<p>" + tr("Version %1").arg(Constants::VERSION) + "</p>"
+ QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
#ifdef APP_ACTIVATION
if (Activation::instance().isActivated())
info += "<p>" + tr("Licensed to: %1").arg("<b>" + Activation::instance().getEmail() + "</b>");
#endif
#ifndef APP_EXTRA
info += "<p>" + tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "<br/>"
+ tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
.arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "</p>";
#endif
info += "<p>" + tr("You may want to try my other apps as well:") + "</p>"
"<ul>"
"<li>" + tr("%1, a YouTube music player")
.arg("<a href='http://flavio.tordini.org/musictube'>Musictube</a>")
+ "</li>"
"<li>" + tr("%1, a music player")
.arg("<a href='http://flavio.tordini.org/musique'>Musique</a>")
+ "</li>"
"</ul>"
"<p>" + tr("Translate %1 to your native language using %2").arg(Constants::NAME)
.arg("<a href='http://www.transifex.net/projects/p/" + QString(Constants::UNIX_NAME) + "/'>Transifex</a>")
+ "</p>"
"<p>"
+ tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.co.za/'>David Nel</a>")
+ "</p>"
#ifndef APP_EXTRA
"<p>" + tr("Released under the <a href='%1'>GNU General Public License</a>")
.arg("http://www.gnu.org/licenses/gpl.html") + "</p>"
#endif
"<p>© 2009-2015 " + Constants::ORG_NAME + "</p>"
"</body></html>";
QLabel *infoLabel = new QLabel(info, this);
infoLabel->setOpenExternalLinks(true);
infoLabel->setWordWrap(true);
layout->addWidget(infoLabel);
QLayout *buttonLayout = new QHBoxLayout();
buttonLayout->setMargin(0);
buttonLayout->setSpacing(0);
buttonLayout->setAlignment(Qt::AlignLeft);
closeButton = new QPushButton(tr("&Close"));
closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
closeButton->setDefault(true);
connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack()));
buttonLayout->addWidget(closeButton);
layout->addLayout(buttonLayout);
}