本文整理汇总了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;
}
}
}
}
示例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: 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;
}
示例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
}
}
}
示例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();
}
示例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);
}
}
示例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)));
}
}
}
}
}
示例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());
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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 ());
}
示例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();
}
示例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();
}