当前位置: 首页>>代码示例>>C++>>正文


C++ QLayout::count方法代码示例

本文整理汇总了C++中QLayout::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayout::count方法的具体用法?C++ QLayout::count怎么用?C++ QLayout::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QLayout的用法示例。


在下文中一共展示了QLayout::count方法的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;
      }
    }
  }
}
开发者ID:grahamperrin,项目名称:lumina,代码行数:25,代码来源:StartMenu.cpp

示例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;
    }
}
开发者ID:thewitcher,项目名称:TrafficLights,代码行数:33,代码来源:TestController.cpp

示例3: cycleContacts

bool CategoryWidget::cycleContacts(FriendWidget* activeChatroomWidget, bool forward)
{
    int index = -1;
    QLayout* currentLayout = nullptr;

    FriendWidget* friendWidget = qobject_cast<FriendWidget*>(activeChatroomWidget);
    if (friendWidget == nullptr)
        return false;

    currentLayout = listLayout->getLayoutOnline();
    index = listLayout->indexOfFriendWidget(friendWidget, true);
    if (index == -1)
    {
        currentLayout = listLayout->getLayoutOffline();
        index = listLayout->indexOfFriendWidget(friendWidget, false);
    }

    index += forward ? 1 : -1;
    for (;;)
    {
        // Bounds checking.
        if (index < 0)
        {
            if (currentLayout == listLayout->getLayoutOffline())
                currentLayout = listLayout->getLayoutOnline();
            else
                return false;

            index = currentLayout->count() - 1;
            continue;
        }
        else if (index >= currentLayout->count())
        {
            if (currentLayout == listLayout->getLayoutOnline())
                currentLayout = listLayout->getLayoutOffline();
            else
                return false;

            index = 0;
            continue;
        }

        GenericChatroomWidget* chatWidget = qobject_cast<GenericChatroomWidget*>(currentLayout->itemAt(index)->widget());
        if (chatWidget != nullptr)
            emit chatWidget->chatroomWidgetClicked(chatWidget);
        return true;
    }

    return false;
}
开发者ID:apprb,项目名称:qTox,代码行数:50,代码来源:categorywidget.cpp

示例4: 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
        }
    }
}
开发者ID:janisozaur,项目名称:ksr2,代码行数:35,代码来源:MainWindow.cpp

示例5: 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();
}
开发者ID:KDE,项目名称:plasma-nm,代码行数:38,代码来源:openconnectauth.cpp

示例6: 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);
  }

}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:35,代码来源:StartupView.cpp

示例7: 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)));
                    }
                }
            }
        }
    }
开发者ID:KDE,项目名称:powerdevil,代码行数:30,代码来源:activitywidget.cpp

示例8: 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());
}
开发者ID:Kwangsub,项目名称:qt-openwebos,代码行数:10,代码来源:src_gui_kernel_qlayout.cpp

示例9: 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);
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:11,代码来源:KoResourceItemChooserContextMenu.cpp

示例10:

QLayout *LayoutInfo::internalLayout(const QWidget *widget)
{
    QLayout *widgetLayout = widget->layout();
    if (widgetLayout && widget->inherits("Q3GroupBox")) {
        if (widgetLayout->count()) {
            widgetLayout = widgetLayout->itemAt(0)->layout();
        } else {
            widgetLayout = 0;
        }
    }
    return widgetLayout;
}
开发者ID:sicily,项目名称:qt4.8.4,代码行数:12,代码来源:layoutinfo.cpp

示例11: checkMoveButtons

void PhotoDrop::checkMoveButtons()
{
	std::cerr << "PhotoDrop::checkMoveButtons()";
	std::cerr << std::endl;
	/* locate mSelected in the set */
	QLayout *alayout = layout();
	if (!alayout)
	{
		std::cerr << "PhotoDrop::checkMoveButtons() No Layout";
		std::cerr << std::endl;
		return;
	}
	
	int count = alayout->count();
	if ((!mSelected) || (count < 2))
	{
    		buttonStatus(PHOTO_SHIFT_NO_BUTTONS);
		return;
	}

	QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
	if (!glayout)
	{
		std::cerr << "PhotoDrop::checkMoveButtons() not GridLayout... not much we can do!";
		std::cerr << std::endl;
    		buttonStatus(PHOTO_SHIFT_NO_BUTTONS);
		return;
	}

	int index = alayout->indexOf(mSelected);
	int selectedRow;
	int selectedColumn;
	int rowSpan;
	int colSpan;
	glayout->getItemPosition(index, &selectedRow, &selectedColumn, &rowSpan, &colSpan);

	int maxRow = (count - 1) / mColumns;
	int maxCol = (count - 1) % mColumns;
	if ((selectedRow == 0) && (selectedColumn == 0))
	{
    		buttonStatus(PHOTO_SHIFT_RIGHT_ONLY);
	}
	else if ((selectedRow == maxRow) && (selectedColumn == maxCol))
	{
    		buttonStatus(PHOTO_SHIFT_LEFT_ONLY);
	}
	else
	{
    		buttonStatus(PHOTO_SHIFT_BOTH);
	}
}
开发者ID:RedCraig,项目名称:retroshare,代码行数:51,代码来源:PhotoDrop.cpp

示例12: dumpWidgetAndChildren

void LayoutDumper::dumpWidgetAndChildren(QDebug& os, const QWidget* w,
                                         int level)
{
    QString padding;
    for (int i = 0; i <= level; i++) {
        padding += "    ";  // 4 spaces per level
    }

    QLayout* layout = w->layout();
    QList<QWidget*> dumped_children;
    if (layout && !layout->isEmpty()) {
        os << padding << "Layout: " << getLayoutInfo(layout);

        QBoxLayout* box_layout = dynamic_cast<QBoxLayout*>(layout);
        if (box_layout) {
            os << ", spacing " <<  box_layout->spacing();
        }
        os << ":\n";

        int num_items = layout->count();
        for (int i = 0; i < num_items; i++) {
            QLayoutItem* layout_item = layout->itemAt(i);
            QString item_info = getLayoutItemInfo(layout_item);
            if (!item_info.isEmpty()) {
                os << padding << "- " << item_info << "\n";
            }

            QWidgetItem* wi = dynamic_cast<QWidgetItem*>(layout_item);
            if (wi && wi->widget()) {
                dumpWidgetAndChildren(os, wi->widget(), level + 1);
                dumped_children.push_back(wi->widget());
            }
        }
    }

    // now output any child widgets that weren't dumped as part of the layout
    QList<QWidget*> widgets = w->findChildren<QWidget*>(
                QString(), Qt::FindDirectChildrenOnly);
    QList<QWidget*> undumped_children;
    foreach (QWidget* child, widgets) {
        if (dumped_children.indexOf(child) == -1) {
            undumped_children.push_back(child);
        }
    }

    if (!undumped_children.empty()) {
        os << padding << "Non-layout children:\n";
        foreach (QWidget* child, undumped_children) {
            dumpWidgetAndChildren(os, child, level + 1);
        }
开发者ID:RudolfCardinal,项目名称:camcops,代码行数:50,代码来源:layoutdumper.cpp

示例13: 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 ());
	}
开发者ID:Kalarel,项目名称:leechcraft,代码行数:49,代码来源:msgformatterwidget.cpp

示例14: hide

 /**
  * Hide this view.
  */
 void PeaksViewer::hide() 
 {
   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())
     {
       // This is important, otherwise the removed widgets sit around on the layout.
       widget->hide();
     }
   }
   QWidget::hide();
 }
开发者ID:jkrueger1,项目名称:mantid,代码行数:18,代码来源:PeaksViewer.cpp

示例15: closeTimerSlot

void LXQtGroupPopup::closeTimerSlot()
{
    bool button_has_dnd_hover = false;
    QLayout* l = layout();
    for (int i = 0; l->count() > i; ++i)
    {
        LXQtTaskButton const * const button = dynamic_cast<LXQtTaskButton const *>(l->itemAt(i)->widget());
        if (0 != button && button->hasDragAndDropHover())
        {
            button_has_dnd_hover = true;
            break;
        }
    }
    if (!button_has_dnd_hover)
        close();
}
开发者ID:jsm222,项目名称:lxqt-panel,代码行数:16,代码来源:lxqtgrouppopup.cpp


注:本文中的QLayout::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。