本文整理汇总了C++中QLayout::takeAt方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayout::takeAt方法的具体用法?C++ QLayout::takeAt怎么用?C++ QLayout::takeAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayout
的用法示例。
在下文中一共展示了QLayout::takeAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initListenerPropLayout
void StartLiveDataDialog::initListenerPropLayout(const QString& inst)
{
// remove previous listener's properties
auto props = m_algorithm->getPropertiesInGroup("ListenerProperties");
for(auto prop = props.begin(); prop != props.end(); ++prop)
{
QString propName = QString::fromStdString((**prop).name());
if ( m_algProperties.contains( propName ) )
{
m_algProperties.remove( propName );
}
}
// update algorithm's properties
m_algorithm->setPropertyValue("Instrument", inst.toStdString());
// create or clear the layout
QLayout *layout = ui.listenerProps->layout();
if ( !layout )
{
QGridLayout *listenerPropLayout = new QGridLayout(ui.listenerProps);
layout = listenerPropLayout;
}
else
{
QLayoutItem *child;
while ((child = layout->takeAt(0)) != NULL)
{
child->widget()->close();
delete child;
}
}
// find the listener's properties
props = m_algorithm->getPropertiesInGroup("ListenerProperties");
// no properties - don't show the box
if ( props.empty() )
{
ui.listenerProps->setVisible(false);
return;
}
auto gridLayout = static_cast<QGridLayout*>( layout );
// add widgets for the listener's properties
for(auto prop = props.begin(); prop != props.end(); ++prop)
{
int row = static_cast<int>(std::distance( props.begin(), prop ));
QString propName = QString::fromStdString((**prop).name());
gridLayout->addWidget( new QLabel(propName), row, 0 );
QLineEdit *propWidget = new QLineEdit();
gridLayout->addWidget( propWidget, row, 1 );
if ( !m_algProperties.contains( propName ) )
{
m_algProperties.append( propName );
}
tie(propWidget, propName, gridLayout);
}
ui.listenerProps->setVisible(true);
}
示例2: SortScrollArea
void StartMenu::SortScrollArea(QScrollArea *area){
//qDebug() << "Sorting Scroll Area:";
//Sort all the items in the scroll area alphabetically
QLayout *lay = area->widget()->layout();
QStringList items;
for(int i=0; i<lay->count(); i++){
items << lay->itemAt(i)->widget()->whatsThis();
}
items.sort();
//qDebug() << " - Sorted Items:" << items;
for(int i=0; i<items.length(); i++){
if(items[i].isEmpty()){ continue; }
//QLayouts are weird in that they can only add items to the end - need to re-insert almost every item
for(int j=0; j<lay->count(); j++){
//Find this item
if(lay->itemAt(j)->widget()->whatsThis()==items[i]){
//Found it - now move it if necessary
//qDebug() << "Found Item:" << items[i] << i << j;
lay->addItem( lay->takeAt(j) );
break;
}
}
}
}
示例3: addSpinBoxes
void MainWindow::addSpinBoxes(bool checked, int count, Range range)
{
if (checked) {
QWidget *w = new QWidget(ui->quantifierValuesGroupBox);
if (ui->quantifierValuesGroupBox->layout() == 0) {
QHBoxLayout *hbl = new QHBoxLayout(ui->quantifierValuesGroupBox);
ui->quantifierValuesGroupBox->setLayout(hbl);
}
ui->quantifierValuesGroupBox->layout()->addWidget(w);
QFormLayout *fl = new QFormLayout(w);
for (int i = 0; i < count; i++) {
QAbstractSpinBox *asb;
if (range == Absolute) {
QSpinBox *sb = new QSpinBox(w);
sb->setMinimum(0);
sb->setMaximum(10000);
asb = sb;
} else {
QDoubleSpinBox *sb = new QDoubleSpinBox(w);
sb->setMinimum(0);
sb->setMaximum(1);
sb->setSingleStep(0.05);
asb = sb;
}
fl->addRow(QString(QChar('A' + i)), asb);
}
} else {
QLayout *fl = ui->quantifierValuesGroupBox->layout();
if (fl != nullptr && fl->count() > 0) {
QWidget *w = fl->takeAt(0)->widget();
delete w;
// there is no mem-leak here, qt handles qobject's children by itself
}
}
}
示例4: setPrimaryWidget
void CollapsiblePairWidget::setPrimaryWidget(QWidget* widget)
{
QLayout* primaryLayout = _primaryContainer->layout();
QLayoutItem *child;
while ((child = primaryLayout->takeAt(0)) != 0)
delete child;
primaryLayout->addWidget(widget);
}
示例5: setSecondaryWidget
void CollapsiblePairWidget::setSecondaryWidget(QWidget* widget)
{
QLayout* secondaryLayout = _secondaryContainer->layout();
QLayoutItem *child;
while ((child = secondaryLayout->takeAt(0)) != 0)
delete child;
secondaryLayout->addWidget(widget);
}
示例6: removeLayoutWidgets
void MainWindow::removeLayoutWidgets() {
if (otherContainer->layout()) {
QLayoutItem *item;
QLayout *layout = otherContainer->layout();
while ((item = layout->takeAt(0))) {
item->widget()->setUserData(Qt::UserRole + 1, nullptr);
delete item->widget();
delete item;
};
}
}
示例7: ResetRangeMeters
void USNavigation::ResetRangeMeters()
{
m_RangeMeters.clear();
QLayout* layout = m_Controls.m_RangeBox->layout();
QLayoutItem *item;
while((item = layout->takeAt(0))) {
if (item->widget()) {
delete item->widget();
}
delete item;
}
}
示例8: handleEmoPackChanged
void MsgFormatterWidget::handleEmoPackChanged ()
{
const QString& emoPack = XmlSettingsManager::Instance ()
.property ("SmileIcons").toString ();
AddEmoticon_->setEnabled (!emoPack.isEmpty ());
IEmoticonResourceSource *src = Core::Instance ().GetCurrentEmoSource ();
if (!src)
return;
const QHash<QImage, QString>& images = src->GetReprImages (emoPack);
QLayout *lay = SmilesTooltip_->layout ();
if (lay)
{
while (lay->count ())
delete lay->takeAt (0);
delete lay;
}
QGridLayout *layout = new QGridLayout (SmilesTooltip_);
layout->setSpacing (0);
layout->setContentsMargins (1, 1, 1, 1);
const int numRows = std::sqrt (static_cast<double> (images.size ())) + 1;
int pos = 0;
for (QHash<QImage, QString>::const_iterator i = images.begin (),
end = images.end (); i != end; ++i)
{
const QIcon icon (QPixmap::fromImage (i.key ()));
QAction *action = new QAction (icon, *i, this);
action->setToolTip (*i);
action->setProperty ("Text", *i);
connect (action,
SIGNAL (triggered ()),
this,
SLOT (insertEmoticon ()));
QToolButton *button = new QToolButton ();
button->setDefaultAction (action);
layout->addWidget (button, pos / numRows, pos % numRows);
++pos;
}
SmilesTooltip_->setLayout (layout);
SmilesTooltip_->adjustSize ();
SmilesTooltip_->setMaximumSize (SmilesTooltip_->sizeHint ());
}
示例9: clearService
void QVideoWidgetPrivate::clearService()
{
if (service) {
QObject::disconnect(service, SIGNAL(destroyed()), q_func(), SLOT(_q_serviceDestroyed()));
if (widgetBackend) {
QLayout *layout = q_func()->layout();
for (QLayoutItem *item = layout->takeAt(0); item; item = layout->takeAt(0)) {
item->widget()->setParent(0);
delete item;
}
delete layout;
widgetBackend->releaseControl();
delete widgetBackend;
widgetBackend = 0;
} else if (rendererBackend) {
rendererBackend->clearSurface();
rendererBackend->releaseControl();
delete rendererBackend;
rendererBackend = 0;
} else {
windowBackend->releaseControl();
delete windowBackend;
windowBackend = 0;
}
currentBackend = 0;
currentControl = 0;
service = 0;
}
}
示例10: emptyWidget
// 删除 widget 中的所有子 widgets
void UiUtil::emptyWidget(QWidget *widget) {
QLayout *layout = widget->layout();
QLayoutItem *item = nullptr;
if (nullptr == layout) {
return;
}
while ((item = layout->takeAt(0)) != nullptr) {
if (item->widget()) {
delete item->widget();
} else {
delete item;
}
}
}
示例11: switchPropertiesEditorWidget
void ActionManagerDialog::switchPropertiesEditorWidget(QWidget* widget)
{
QLayout *layout = mPropertiesEditorParentWidget->layout();
if (! layout)
return;
QLayoutItem* item = layout->takeAt(0);
if (item && item->widget())
item->widget()->hide();
if (widget) {
layout->addWidget(widget);
if (widget->isHidden())
widget->show();
}
}
示例12: on_FieldName__activated
void MatchConfigDialog::on_FieldName__activated (int idx)
{
const auto& data = Ui_.FieldName_->itemData (idx).value<ANFieldData> ();
Ui_.DescriptionLabel_->setText (data.Description_);
QLayout *lay = Ui_.ConfigWidget_->layout ();
QLayoutItem *oldItem = 0;
while ((oldItem = lay->takeAt (0)) != 0)
{
delete oldItem->widget ();
delete oldItem;
}
CurrentMatcher_ = TypedMatcherBase::Create (data.Type_, data);
if (CurrentMatcher_)
lay->addWidget (CurrentMatcher_->GetConfigWidget ());
else
lay->addWidget (new QLabel (tr ("Invalid matcher type %1.")
.arg (QVariant::typeToName (data.Type_))));
}
示例13: us
void
RadioWidget::refresh( const unicorn::Session& session )
{
if ( session.isValid() )
{
m_movie->stop();
if ( session.youRadio() )
{
unicorn::UserSettings us( session.user().name() );
QString stationUrl = us.value( "lastStationUrl", "" ).toString();
QString stationTitle = us.value( "lastStationTitle", tr( "A Radio Station" ) ).toString();
ui->nowPlayingFrame->setVisible( !stationUrl.isEmpty() );
RadioStation lastStation( stationUrl );
lastStation.setTitle( stationTitle );
ui->lastStation->setStation( lastStation, stationTitle );
ui->lastStation->setObjectName( "station" );
style()->polish( ui->lastStation );
ui->library->setStation( RadioStation::library( session.user() ), tr( "My Library Radio" ), tr( "Music you know and love" ) );
ui->mix->setStation( RadioStation::mix( session.user() ), tr( "My Mix Radio" ), tr( "Your library plus new music" ) );
ui->rec->setStation( RadioStation::recommendations( session.user() ), tr( "My Recommended Radio" ), tr( "New music from Last.fm" ) );
ui->friends->setStation( RadioStation::friends( session.user() ), tr( "My Friends' Radio" ), tr( "Music your friends like" ) );
ui->neighbours->setStation( RadioStation::neighbourhood( session.user() ), tr( "My Neighbourhood Radio" ), tr ( "Music from listeners like you" ) );
if ( m_currentUsername != session.user().name() )
{
m_currentUsername = session.user().name();
// clear the recent stations
QLayout* recentStationsLayout = ui->recentStations->layout();
while ( recentStationsLayout->count() )
{
QLayoutItem* item = recentStationsLayout->takeAt( 0 );
delete item->widget();
delete item;
}
// fetch recent stations
connect( session.user().getRecentStations( MAX_RECENT_STATIONS ), SIGNAL(finished()), SLOT(onGotRecentStations()));
}
ui->stackedWidget->setCurrentWidget( ui->mainPage );
}
else
{
ui->listen->setVisible( session.registeredWebRadio() );
ui->stackedWidget->setCurrentWidget( ui->nonSubPage );
ui->title->setText( tr( "Subscribe to listen to radio, only %1 a month" ).arg( session.subscriptionPriceString() ) );
ui->subscribe->setVisible( session.subscriberRadio() );
}
}
else
{
ui->stackedWidget->setCurrentWidget( ui->spinnerPage );
m_movie->start();
}
}
示例14: setupTabs
//----------------------------------------------------------------------------
void DynamicEditor::setupTabs(QDomDocument *elmerDefs, const QString &Section, int ID)
{
// Clear:
//-------
this->ID = ID;
hash.clear();
QLayout *layout = this->layout();
if(layout != NULL) {
QLayoutItem *item;
while((item = layout->takeAt(0)) != 0)
delete item;
if(tabWidget != NULL) {
tabWidget->clear();
delete tabWidget;
}
delete layout;
}
// Get root element of elmerDefs:
//-------------------------------
root = elmerDefs->documentElement();
tabWidget = new QTabWidget;
//tabWidget->setTabShape(QTabWidget::Triangular);
tabWidget->setUsesScrollButtons(true);
tabWidget->setElideMode(Qt::ElideNone);
all_stuff = root.firstChildElement("ALL");
element = root.firstChildElement("PDE");
tabs = 0;
while(!element.isNull()) {
name = element.firstChildElement("Name");
QGridLayout *grid = new QGridLayout;
int params = 0;
for( int iter=0; iter<2; iter++ )
{
if ( iter==0 ) {
if ( name.text().trimmed() == "General" ) continue;
section = all_stuff.firstChildElement(Section);
} else {
section = element.firstChildElement(Section);
}
param = section.firstChildElement("Parameter");
// ML: Added argument "Parameter" for nextSiblingElement(), 5. August 2010:
for( ; !param.isNull(); param=param.nextSiblingElement("Parameter"), params++ ) {
// label
QString widget_type = param.attribute("Widget","Edit");
QString widget_enabled = param.attribute("Enabled","True");
QString widget_visible = param.attribute("Visible","True");
QString paramType = param.firstChildElement("Type").text().trimmed();
QString labelName = param.firstChildElement("Name").text().trimmed();
QString sifName = param.firstChildElement("SifName").text().trimmed();
if ( sifName == "" ) sifName = labelName;
QString paramDefault = param.firstChildElement("DefaultValue").text().trimmed();
QString whatis = param.firstChildElement("Whatis").text().trimmed();
QString statusTip = param.firstChildElement("StatusTip").text().trimmed();
QString fullName = "/"+name.text().trimmed()+"/"+Section+"/"+labelName+"/"+QString::number(ID);
h.widget = NULL;
if ( widget_type == "Edit" ) {
DynLineEdit *edit = new DynLineEdit;
h.widget = edit->lineEdit;
edit->lineEdit->setText(paramDefault);
edit->name = fullName;
connect(edit->lineEdit, SIGNAL(returnPressed()),
edit, SLOT(editSlot()));
connect(edit->lineEdit, SIGNAL(textChanged(QString)),
this, SLOT(textChangedSlot(QString)));
} else if (widget_type == "TextEdit") {
QTextEdit *textEdit = new QTextEdit;
// set height to 5..8 lines of current font:
QFont currentFont = textEdit->currentFont();
QFontMetrics fontMetrics(currentFont);
int fontHeight = fontMetrics.height();
textEdit->setMinimumHeight(5*fontHeight);
textEdit->setMaximumHeight(8*fontHeight);
h.widget = textEdit;
} else if ( widget_type == "Combo" ) {
QComboBox *combo = new QComboBox;
h.widget = combo;
// combo->setObjectName(labelName); // removed 30. sept. 2008, ML
int count = 0, active=0;
QDomElement item = param.firstChildElement("Item");
for( ; !item.isNull(); item=item.nextSiblingElement("Item") ) {
QString itemType = item.attribute( "Type", "" );
//.........这里部分代码省略.........
示例15: RebuildList
//-----------------------------------------------------------------------------
//! Rebuilt the trip history list layout, which updates the trip history list
//-----------------------------------------------------------------------------
void tTripHistoryList::RebuildList(tFocusAction focusAction)
{
m_WidgetToDataMap.clear();
QWidget* pFocusWidget = 0;
pFocusWidget = focusWidget();
QLayout* pLayout = layout();
// Rebuilding the layout. may need to record focus index of current widget, and record current QScrollArea vertical position.
int focusIndex = -1;
int verticalScrollPos = -1;
tScrollArea* pScrollArea = GetScrollAreaLayout(pLayout);
if (pScrollArea != 0)
{
QScrollBar* pVerticalBar = pScrollArea->verticalScrollBar();
verticalScrollPos = pVerticalBar->value();
QVBoxLayout* pVBoxLayout = GetTripWidgetLayout(pScrollArea);
if (pVBoxLayout != 0)
{
focusIndex = pVBoxLayout->indexOf(pFocusWidget);
}
}
// NB: Deleting layouts doesn't delete the widgets that are added to it
// because the QWidgets are parented to the QWidget that owns the QLayout.
// Because of this, explicitly delete the child widgets first before they're
// recreated in tMfdUiHeroicFactory::CreateTripHistoryListLayout
// SM: Only delete widgets in the layout
if (pLayout != 0)
{
QLayoutItem* item;
while ( ( item = pLayout->takeAt( 0 ) ) != 0 )
{
delete item->widget();
delete item;
}
delete pLayout;
}
//Build a new layout
QLayout* pNewLayout = m_MfdUiHeroicFactory.CreateTripHistoryListLayout(this);
setLayout(pNewLayout);
// Restore focus of current widget if necessary, restore QScrollArea position.
pScrollArea = GetScrollAreaLayout(pNewLayout);
if (pScrollArea != 0 && focusIndex != -1)
{
if (focusAction == KEEP_FOCUS)
{
QVBoxLayout* pVBoxLayout = GetTripWidgetLayout(pScrollArea);
if (pVBoxLayout != 0)
{
QLayoutItem* pNewLayoutItem = pVBoxLayout->itemAt(focusIndex);
if (dynamic_cast<QWidgetItem *>(pNewLayoutItem))
{
QWidget* pNewFocusWidget = pNewLayoutItem->widget();
pNewFocusWidget->setFocus();
}
}
}
if (verticalScrollPos != -1)
{
pScrollArea->verticalScrollBar()->setValue(verticalScrollPos);
}
}
}