本文整理汇总了C++中QLayout::itemAt方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayout::itemAt方法的具体用法?C++ QLayout::itemAt怎么用?C++ QLayout::itemAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayout
的用法示例。
在下文中一共展示了QLayout::itemAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
}
}
示例2: unload
void TestController::unload() {
//Inputs
QLayout* layout = getView().getUi().grx_test_inputs->layout();
for (int i = layout->count() - 1; i >= 0; --i) {
QLayoutItem* item = layout->itemAt(i);
GuiGrapher* g = dynamic_cast<GuiGrapher*> (item->widget());
if (g) {
QObject::disconnect(g, SIGNAL(onChangeInputValue()), this,
SLOT(onInputValueChanged()));
}
layout->removeItem(item);
delete item->widget();
delete item;
}
//Rules
getView().getUi().lsw_test_rules->clear();
getView().getUi().lsw_test_rules_activation->clear();
//Outputs
layout = getView().getUi().grx_test_outputs->layout();
for (int i = layout->count() - 1; i >= 0; --i) {
QLayoutItem* item = layout->itemAt(i);
GuiGrapher* g = dynamic_cast<GuiGrapher*> (item->widget());
if (g) {
QObject::disconnect(this, SIGNAL(forceUpdate()), g, SLOT(updateUi()));
}
layout->removeItem(item);
delete item->widget();
delete item;
}
}
示例3: showDetailsForItem
void StartupView::showDetailsForItem( const QModelIndex & index )
{
QLayout * layout = m_projectDetailView->layout();
for( int i = 0; i < layout->count(); i++ )
{
delete layout->itemAt(i)->widget();
layout->removeItem(layout->itemAt(i));
}
QString name = m_templateListModel->data(index,Qt::ToolTipRole).toString();
QString description = m_templateListModel->data(index,Qt::WhatsThisRole).toString();
if( ! name.isEmpty() )
{
auto nameLabel = new QLabel(name);
nameLabel->setStyleSheet("QLabel { font: bold }");
layout->addWidget(nameLabel);
}
if( ! description.isEmpty() )
{
auto descriptionLabel = new QTextEdit(description);
descriptionLabel->setStyleSheet("QTextEdit { border: none; }");
descriptionLabel->setReadOnly(true);
layout->addWidget(descriptionLabel);
}
}
示例4: changeScreen
void MainWindow::changeScreen(QWidget* screen){
mCurrentScreen = screen;
QLayout* layout = ui.screenContainer->layout();
layout->removeWidget(layout->itemAt(0)->widget());
layout->addWidget(mCurrentScreen);
}
示例5:
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_layout_at (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QLayout *layout = self->v8_to_qobject<QLayout> (Args.This ());
if (layout) {
if (Args.Length () > 0) {
QWidget *widget = layout->itemAt (v8_to_int32 (Args[0]))->widget ();
if (widget) {
result = self->create_v8_qwidget (widget);
}
}
}
}
return scope.Close (result);
}
示例6: setIconSize
void QToolBar::setIconSize(const QSize &iconSize)
{
Q_D(QToolBar);
QSize sz = iconSize;
if (!sz.isValid()) {
QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget());
if (mw && mw->layout()) {
QLayout *layout = mw->layout();
int i = 0;
QLayoutItem *item = 0;
do {
item = layout->itemAt(i++);
if (item && (item->widget() == this))
sz = mw->iconSize();
} while (!sz.isValid() && item != 0);
}
}
if (!sz.isValid()) {
const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);
sz = QSize(metric, metric);
}
if (d->iconSize != sz) {
d->iconSize = sz;
setMinimumSize(0, 0);
emit iconSizeChanged(d->iconSize);
}
d->explicitIconSize = iconSize.isValid();
d->layout->invalidate();
}
示例7: formLoginClicked
// Writes the user input from the form into the oc_auth_form structs we got from
// libopenconnect, and wakes the worker thread up to try to log in and obtain a
// cookie with this data
void OpenconnectAuthWidget::formLoginClicked()
{
Q_D(OpenconnectAuthWidget);
const int lastIndex = d->ui.loginBoxLayout->count() - 1;
QLayout *layout = d->ui.loginBoxLayout->itemAt(d->passwordFormIndex)->layout();
struct oc_auth_form *form = (struct oc_auth_form *) d->ui.loginBoxLayout->itemAt(lastIndex)->widget()->property("openconnect_form").value<quintptr>();
for (int i = 0; i < layout->count(); i++) {
QLayoutItem *item = layout->itemAt(i);
QWidget *widget = item->widget();
if (widget && widget->property("openconnect_opt").isValid()) {
struct oc_form_opt *opt = (struct oc_form_opt *) widget->property("openconnect_opt").value<quintptr>();
const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
QLineEdit *le = qobject_cast<QLineEdit*>(widget);
QByteArray text = le->text().toUtf8();
openconnect_set_option_value(opt, text.data());
if (opt->type == OC_FORM_OPT_TEXT) {
d->secrets.insert(key, le->text());
} else {
d->tmpSecrets.insert(key, le->text());
}
} else if (opt->type == OC_FORM_OPT_SELECT) {
QComboBox *cbo = qobject_cast<QComboBox*>(widget);
QByteArray text = cbo->itemData(cbo->currentIndex()).toString().toAscii();
openconnect_set_option_value(opt, text.data());
d->secrets.insert(key,cbo->itemData(cbo->currentIndex()).toString());
}
}
}
deleteAllFromLayout(d->ui.loginBoxLayout);
d->workerWaiting.wakeAll();
}
示例8: QLineEdit
AskColorDialog::AskColorDialog(QColor initial, QWidget *parent) :
QColorDialog(initial, parent)
{
hexcode = new QLineEdit( this);
hexcode->setMaxLength(9);
QLayout *layout = this->layout();
// find a nice spot in the layout...
for (int k=0; k<2; k++) if (layout) {
for (int i=2; i>=0; i--) {
QLayoutItem *test = layout->itemAt(i);
if (test) if (test->layout()) {
layout = test->layout();
//qDebug("ok %d (%d)",i,k);
break;
}
}
}
if (layout) layout->addWidget(hexcode);
connect(hexcode,SIGNAL(textEdited(QString)),this,SLOT(setHex()));
connect(this,SIGNAL(currentColorChanged(QColor)),this,SLOT(updateHex()));
setOption(ShowAlphaChannel, true);
updateHex();
setHex();
}
示例9: QWidget
ActivityWidget::ActivityWidget(const QString& activity, QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::ActivityWidget)
, m_profilesConfig(KSharedConfig::openConfig("powermanagementprofilesrc", KConfig::SimpleConfig | KConfig::CascadeConfig))
, m_activity(activity)
, m_activityConsumer(new KActivities::Consumer(this))
, m_actionEditWidget(new ActionEditWidget(QString("Activities/%1/SeparateSettings").arg(activity)))
{
m_ui->setupUi(this);
m_ui->separateSettingsLayout->addWidget(m_actionEditWidget);
for (int i = 0; i < m_ui->specialBehaviorLayout->count(); ++i) {
QWidget *widget = m_ui->specialBehaviorLayout->itemAt(i)->widget();
if (widget) {
widget->setVisible(false);
connect(m_ui->specialBehaviorRadio, SIGNAL(toggled(bool)), widget, SLOT(setVisible(bool)));
} else {
QLayout *layout = m_ui->specialBehaviorLayout->itemAt(i)->layout();
if (layout) {
for (int j = 0; j < layout->count(); ++j) {
QWidget *widget = layout->itemAt(j)->widget();
if (widget) {
widget->setVisible(false);
connect(m_ui->specialBehaviorRadio, SIGNAL(toggled(bool)), widget, SLOT(setVisible(bool)));
}
}
}
}
}
示例10: 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;
}
示例11: setSpacingAt
void NLayoutPrototype::setSpacingAt(int index, int spacing)
{
QLayout *layout = qscriptvalue_cast<QLayout *>(thisObject());
if (layout) {
layout->removeItem(layout->itemAt(index));
dynamic_cast<QBoxLayout *>(layout)->insertSpacing(index, spacing);
}
}
示例12: paintLayout
//! [0]
static void paintLayout(QPainter *painter, QLayoutItem *item)
{
QLayout *layout = item->layout();
if (layout) {
for (int i = 0; i < layout->count(); ++i)
paintLayout(painter, layout->itemAt(i));
}
painter->drawRect(item->geometry());
}
示例13:
// Never used.
// Get the widget in the last group box at the position 'pos'.
QWidget *PinConfig::outWidgetAt(int pos)
{
QLayout *groupBoxLayout = this->subConfigGroupBox->layout();
if (!groupBoxLayout)
return NULL;
QLayoutItem *layoutItem = groupBoxLayout->itemAt(pos);
if (!layoutItem)
return NULL;
return layoutItem->widget();
}
示例14: showPeaksTableColumnOptions
/**
* Slot called when the user wants to see the dialog for selecting
* what columns are visible in the tables of peaks.
*/
void PeaksViewer::showPeaksTableColumnOptions()
{
std::set<QString> areShown;
// get the list of all the columns that are already shown
QLayout* layout = this->layout();
const int size = layout->count();
for(int i = 0; i < size; ++i)
{
auto item = layout->itemAt(i);
if(auto widget = item->widget())
{
if (auto table = dynamic_cast<PeaksWorkspaceWidget *>(widget))
{
auto shown = table->getShownColumns();
areShown.insert(shown.begin(), shown.end());
}
}
}
// show the dialog box
PeaksTableColumnsDialog dialog(this);
dialog.setVisibleColumns(areShown);
dialog.exec();
auto result = static_cast<QDialog::DialogCode>(dialog.result());
if (result != QDialog::DialogCode::Accepted)
return;
// set what columns to show
auto toShow = dialog.getVisibleColumns();
for(int i = 0; i < size; ++i)
{
auto item = layout->itemAt(i);
if(auto widget = item->widget())
{
if (auto table = dynamic_cast<PeaksWorkspaceWidget *>(widget))
{
table->setShownColumns(toShow);
}
}
}
}
示例15: setVisible
void KoLineEditAction::setVisible(bool showAction)
{
QLayout* currentLayout = defaultWidget()->layout();
this->QAction::setVisible(showAction);
for(int i=0;i<currentLayout->count();i++) {
currentLayout->itemAt(i)->widget()->setVisible(showAction);
}
defaultWidget()->setVisible(showAction);
}