本文整理汇总了C++中QLayout类的典型用法代码示例。如果您正苦于以下问题:C++ QLayout类的具体用法?C++ QLayout怎么用?C++ QLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeScreen
void MainWindow::changeScreen(QWidget* screen){
mCurrentScreen = screen;
QLayout* layout = ui.screenContainer->layout();
layout->removeWidget(layout->itemAt(0)->widget());
layout->addWidget(mCurrentScreen);
}
示例2: deleteSingleContactItem
bool MTPageNym_AltLocation::deleteSingleContactItem(GroupBoxContactItems * pGroupBox, QWidget * pWidget)
{
if (nullptr == pGroupBox || nullptr == pWidget)
return false;
// We have to remove the radio button from the buttongroup.
QLayout * pItemLayout = pWidget->layout(); // Combo, Line Edit, Radio, Delete
if (nullptr != pItemLayout)
{
const int nIndexRadioBtn = 2; // todo hardcoding.
QWidget * pRadioBtnWidget = pItemLayout->itemAt(nIndexRadioBtn)->widget();
if (nullptr != pRadioBtnWidget)
{
QRadioButton * pRadioBtn = dynamic_cast<QRadioButton *>(pRadioBtnWidget);
if (nullptr != pRadioBtn)
{
pGroupBox->removeRadioButton(pRadioBtn);
}
}
}
// --------------------------------------
pGroupBox->layout()->removeWidget(pWidget);
pWidget->setParent(nullptr);
pWidget->disconnect();
pWidget->deleteLater();
PrepareOutputData();
return true;
}
示例3: 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
}
示例4: renderLegend
/*!
Print the legend into a given rectangle.
\param plot Plot widget
\param painter Painter
\param rect Bounding rectangle
*/
void QwtPlotRenderer::renderLegend( const QwtPlot *plot,
QPainter *painter, const QRectF &rect ) const
{
if ( !plot->legend() || plot->legend()->isEmpty() )
return;
QLayout *l = plot->legend()->contentsWidget()->layout();
if ( l == 0 || !l->inherits( "QwtDynGridLayout" ) )
return;
QwtDynGridLayout *legendLayout = ( QwtDynGridLayout * )l;
uint numCols = legendLayout->columnsForWidth( rect.width() );
QList<QRect> itemRects =
legendLayout->layoutItems( rect.toRect(), numCols );
int index = 0;
for ( int i = 0; i < legendLayout->count(); i++ )
{
QLayoutItem *item = legendLayout->itemAt( i );
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipRect( itemRects[index] );
renderLegendItem( plot, painter, w, itemRects[index] );
index++;
painter->restore();
}
}
}
示例5: update
void CCanvasQuickView::update(CDiagram *d)
{
QRectF r;
CDiagramEditor *editor = NULL;
CDiagramView *view = NULL;
QLayout *layout = NULL;
layout = ui->m_miniViewHolder->layout();
if (layout && m_view)
{
layout->removeWidget(m_view);
m_view->setParent(NULL);
m_view = NULL;
}
m_d = d;
if (m_d)
{
editor = dynamic_cast<CDiagramEditor*>(m_d->getMainView());
if (editor)
{
view = editor->diagramView();
if (view)
{
view->setParent(this);
layout->addWidget(view);
m_view = view;
}
}
}
}
示例6: ListOfMaterial
// Display the model's list of material
void ModelProperties::displayListOfMaterial(bool show)
{
if (show)
{
if (NULL == m_pListOfMaterial)
{
m_pListOfMaterial= new ListOfMaterial(m_pOpenglView, materialListGroup);
QLayout *pLayout = materialListGroup->layout();
if (NULL == pLayout)
{
pLayout= new QVBoxLayout;
materialListGroup->setLayout(pLayout);
}
pLayout->addWidget(m_pListOfMaterial);
m_pListOfMaterial->showOnlyItemList(true);
QList<GLC_Material*> materialList= m_FileEntry.getWorld().listOfMaterials();
m_pListOfMaterial->CreateOrUpdate(materialList);
}
m_pListOfMaterial->show();
}
else
{
m_pListOfMaterial->hide();
}
}
示例7: qWarning
Group *Widget::createGroup(int groupId)
{
Group* g = GroupList::findGroup(groupId);
if (g)
{
qWarning() << "Widget::createGroup: Group already exists";
return g;
}
QString groupName = QString("Groupchat #%1").arg(groupId);
Group* newgroup = GroupList::addGroup(groupId, groupName, true);
QLayout* layout = contactListWidget->getGroupLayout();
layout->addWidget(newgroup->getGroupWidget());
newgroup->getGroupWidget()->updateStatusLight();
Core* core = Nexus::getCore();
connect(settingsWidget, &SettingsWidget::compactToggled, newgroup->getGroupWidget(), &GenericChatroomWidget::onCompactChanged);
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
connect(newgroup->getGroupWidget(), SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->getChatForm(), SLOT(focusInput()));
connect(newgroup->getChatForm(), SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
connect(newgroup->getChatForm(), SIGNAL(sendAction(int,QString)), core, SLOT(sendGroupAction(int,QString)));
connect(newgroup->getChatForm(), &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
return newgroup;
}
示例8: 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);
} else {
qWarning() << QCoreApplication::translate("QFormBuilder", "The layout type `%1' is not supported.").arg(layoutName);
}
return l;
}
示例9: qDebug
void Widget::addFriend(int friendId, const QString &userId)
{
qDebug() << "Adding friend with id "+userId;
Friend* newfriend = FriendList::addFriend(friendId, userId);
QLayout* layout = contactListWidget->getFriendLayout(Status::Offline);
layout->addWidget(newfriend->widget);
connect(newfriend->widget, SIGNAL(friendWidgetClicked(FriendWidget*)), this, SLOT(onFriendWidgetClicked(FriendWidget*)));
connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
connect(newfriend->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString)));
connect(newfriend->chatForm, SIGNAL(sendFile(int32_t, QString, QString, long long)), core, SLOT(sendFile(int32_t, QString, QString, long long)));
connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
connect(newfriend->chatForm, SIGNAL(hangupCall(int)), core, SLOT(hangupCall(int)));
connect(newfriend->chatForm, SIGNAL(startCall(int)), core, SLOT(startCall(int)));
connect(newfriend->chatForm, SIGNAL(startVideoCall(int,bool)), core, SLOT(startCall(int,bool)));
connect(newfriend->chatForm, SIGNAL(cancelCall(int,int)), core, SLOT(cancelCall(int,int)));
connect(newfriend->chatForm, SIGNAL(micMuteToggle(int)), core, SLOT(micMuteToggle(int)));
connect(core, &Core::fileReceiveRequested, newfriend->chatForm, &ChatForm::onFileRecvRequest);
connect(core, &Core::avInvite, newfriend->chatForm, &ChatForm::onAvInvite);
connect(core, &Core::avStart, newfriend->chatForm, &ChatForm::onAvStart);
connect(core, &Core::avCancel, newfriend->chatForm, &ChatForm::onAvCancel);
connect(core, &Core::avEnd, newfriend->chatForm, &ChatForm::onAvEnd);
connect(core, &Core::avRinging, newfriend->chatForm, &ChatForm::onAvRinging);
connect(core, &Core::avStarting, newfriend->chatForm, &ChatForm::onAvStarting);
connect(core, &Core::avEnding, newfriend->chatForm, &ChatForm::onAvEnding);
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
connect(core, &Core::avMediaChange, newfriend->chatForm, &ChatForm::onAvMediaChange);
}
示例10: widgetSelected
void WidgetInspector::widgetSelected(const QModelIndex &index)
{
if (index.isValid()) {
QObject *obj = index.data(ObjectModel::ObjectRole).value<QObject*>();
QWidget *widget = qobject_cast<QWidget*>(obj);
QLayout* layout = qobject_cast<QLayout*>(obj);
if (!widget && layout) {
widget = layout->parentWidget();
}
ui->widgetPropertyWidget->setObject(obj);
ui->widgetPreviewWidget->setWidget(widget);
setActionsEnabled(widget != 0);
if (widget && qobject_cast<QDesktopWidget*>(widget) == 0) {
m_overlayWidget->placeOn(widget);
} else {
m_overlayWidget->placeOn(0);
}
} else {
ui->widgetPropertyWidget->setObject(0);
ui->widgetPreviewWidget->setWidget(0);
m_overlayWidget->placeOn(0);
setActionsEnabled(false);
}
}
示例11: QWidget
RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f)
, mRootNode(0)
{
osgViewer::CompositeViewer& viewer = CompositeViewer::get();
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
//ds->setNumMultiSamples(8);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->windowName = "";
traits->windowDecoration = true;
traits->x = 0;
traits->y = 0;
traits->width = width();
traits->height = height();
traits->doubleBuffer = true;
traits->alpha = ds->getMinimumNumAlphaBits();
traits->stencil = ds->getMinimumNumStencilBits();
traits->sampleBuffers = ds->getMultiSamples();
traits->samples = ds->getNumMultiSamples();
// Doesn't make much sense as we're running on demand updates, and there seems to be a bug with the refresh rate when running multiple QGLWidgets
traits->vsync = false;
mView = new osgViewer::View;
osg::ref_ptr<osgQt::GraphicsWindowQt> window = new osgQt::GraphicsWindowQt(traits.get());
QLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(window->getGLWidget());
setLayout(layout);
// Pass events through this widget first
window->getGLWidget()->installEventFilter(this);
mView->getCamera()->setGraphicsContext(window);
mView->getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
mView->getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
mView->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager;
lightMgr->setStartLight(1);
lightMgr->setLightingMask(Mask_Lighting);
mRootNode = lightMgr;
mView->getCamera()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
mView->getCamera()->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
mView->setSceneData(mRootNode);
// Press S to reveal profiling stats
mView->addEventHandler(new osgViewer::StatsHandler);
mView->getCamera()->setCullMask(~(Mask_UpdateVisitor));
viewer.addView(mView);
viewer.setDone(false);
viewer.realize();
}
示例12: CrmaccountMergeResultPagePrivate
CrmaccountMergeResultPagePrivate(QWizardPage *parent)
: _parent(parent)
{
_crmaccount = new crmaccount();
_crmaccount->_save->setVisible(false);
_crmaccount->_close->setVisible(false);
QString errmsg;
bool ok = false;
_obsoletemqlstr = MQLUtil::mqlLoad("crmaccountmerge", "wip", errmsg, &ok);
if (!ok)
ErrorReporter::error(QtCriticalMsg, _parent,
QT_TRANSLATE_NOOP("CrmaccountMergeResultPage",
"Getting Source CRM Accounts"),
errmsg, __FILE__, __LINE__);
ParameterList params;
params.append("mode", "view");
_crmaccount->set(params);
QWidget *sa = _parent->findChild<QWidget*>("_resultScrollAreaContents");
QLayout *lyt = sa ? sa->layout() : 0;
if (lyt)
lyt->addWidget(_crmaccount);
else
ErrorReporter::error(QtWarningMsg, _parent,
QT_TRANSLATE_NOOP("CrmaccountMergeResultPage",
"Could not draw CRM Account"),
QT_TRANSLATE_NOOP("CrmaccountMergeResultPage",
"Could not find the portion of the window "
"in which to draw the target CRM Account."));
};
示例13: m_clearText
ItemSelectorWidget::ItemSelectorWidget( QWidget* parent )
:StylableWidget(parent), m_clearText( false )
{
QLayout* layout = new FlowLayout( this, 0, 0, 0 );
layout->setContentsMargins( 0, 0, 0, 0 );
layout->setSpacing( 0 );
}
示例14: QWidget
SymbolDialog::SymbolDialog(QWidget* parent)
: QWidget(parent, Qt::WindowFlags(Qt::Dialog | Qt::Window))
{
setupUi(this);
int idx = 0;
int currentIndex = 0;
for (const ScoreFont& f : ScoreFont::scoreFonts()) {
fontList->addItem(f.name());
if (f.name() == "Bravura")
currentIndex = idx;
++idx;
}
fontList->setCurrentIndex(currentIndex);
setWindowTitle(tr("MuseScore: Symbols"));
QLayout* l = new QVBoxLayout();
frame->setLayout(l);
createSymbolPalette();
QScrollArea* sa = new PaletteScrollArea(sp);
l->addWidget(sa);
sp->setAcceptDrops(false);
sp->setDrawGrid(true);
sp->setSelectable(true);
connect(systemFlag, SIGNAL(stateChanged(int)), SLOT(systemFlagChanged(int)));
connect(fontList, SIGNAL(currentIndexChanged(int)), SLOT(systemFontChanged(int)));
sa->setWidget(sp);
}
示例15: printLegend
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const
{
if ( !d_legend || d_legend->isEmpty() )
return;
QLayout *l = d_legend->contentsWidget()->layout();
if ( l == 0 || !l->inherits("QwtDynGridLayout") )
return;
QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l;
uint numCols = legendLayout->columnsForWidth(rect.width());
QValueList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
int index = 0;
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator)
{
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipping(TRUE);
QwtPainter::setClipRect(painter, itemRects[index]);
printLegendItem(painter, w, itemRects[index]);
index++;
painter->restore();
}
}
}