void QVariantListPropertyWidgetItem::setEditValue(const QVariant& value) { QGridLayout* layout = qobject_cast<QGridLayout*>( editWidget()->layout() ); // Clear out any old data... editorItems.clear(); values.clear(); layout->removeItem( layout->itemAt( layout->indexOf( listItems ) ) ); listItems->deleteLater(); // Set new value listItems = new QWidget( editWidget() ); listItems->setContentsMargins( 0, 0, 0, 0 ); listItems->setLayout( new QVBoxLayout() ); listItems->layout()->setMargin( 0 ); listItems->layout()->setSpacing( 0 ); layout->addWidget( listItems, 1, 0, 1, 2 ); // Rebuild list from this QVariantList items = value.toList(); if( items.count() > 0 ) { for( int i = 0; i < items.count(); ++i ) { addItem( items[i] ); } } GluonCreator::PropertyWidgetItem::setEditValue(value); }
void DialogEditSIMDRegister::hideColumns(EntriesCols afterLastToHide) { QGridLayout* layout = dynamic_cast<QGridLayout*>(this->layout()); for(int col=ENTRIES_FIRST_COL;col<afterLastToHide;++col) { int i=numBytes-1-(col-ENTRIES_FIRST_COL); Q_ASSERT(0<i && std::size_t(i)<bytes.size()); columnLabels[i]->hide(); // Spanned entries shouldn't just be hidden. If they are still in the grid, // then we get extra spacing between invisible columns, which is unwanted. // So we have to also remove them from the layout. layout->removeWidget(bytes[i]); bytes[i]->hide(); layout->removeWidget(words[i/2]); words[i/2]->hide(); layout->removeWidget(dwords[i/4]); dwords[i/4]->hide(); layout->removeWidget(qwords[i/8]); qwords[i/8]->hide(); layout->removeWidget(floats32[i/4]); floats32[i/4]->hide(); layout->removeWidget(floats64[i/8]); floats64[i/8]->hide(); } layout->removeItem(hexSignOKCancelLayout); hexSignOKCancelLayout->setParent(nullptr); layout->addLayout(hexSignOKCancelLayout, ROW_AFTER_ENTRIES, afterLastToHide, 1, TOTAL_COLS-afterLastToHide); }
void DeviceStatusForm::updateGUIPorts (void) { // refresh device informations m_pDevice->setDevice(m_pDevice->deviceType(), m_pDevice->deviceID()); DevicePortList ports = m_pDevice->ports(); // clear the GUI QGridLayout *pLayout = static_cast<QGridLayout *> (layout()); for (int i = pLayout->count() - 1; i >= 0; --i) { QLayoutItem *pItem = pLayout->itemAt(i); if (pItem) { pLayout->removeItem(pItem); if (pItem->widget()) delete pItem->widget(); delete pItem; } } m_midiActivityLEDs.clear(); // rebuild the GUI for (int i = 0; i < ports.size(); ++i) { MidiActivityLED *pLED = new MidiActivityLED(); m_midiActivityLEDs.push_back(pLED); pLayout->addWidget(pLED, i, 0); QLabel *pLabel = new QLabel( m_pDevice->deviceTypeName() + ' ' + m_pDevice->driverName() + ' ' + ports[i]->portName()); pLayout->addWidget(pLabel, i, 1, Qt::AlignLeft); } }
void DialogEditSIMDRegister::resetLayout() { QGridLayout* layout = dynamic_cast<QGridLayout*>(this->layout()); for(int col=ENTRIES_FIRST_COL;col<TOTAL_COLS;++col) { int i=numBytes-1-(col-ENTRIES_FIRST_COL); columnLabels[i]->show(); const auto& byte=bytes[i]; layout->addWidget(byte,BYTES_ROW,byte->column(),1,byte->colSpan()); byte->show(); const auto& word=words[i/2]; layout->addWidget(word,WORDS_ROW,word->column(),1,word->colSpan()); word->show(); const auto& dword=dwords[i/4]; layout->addWidget(dword,DWORDS_ROW,dword->column(),1,dword->colSpan()); dword->show(); const auto& qword=qwords[i/8]; layout->addWidget(qword,QWORDS_ROW,qword->column(),1,qword->colSpan()); qword->show(); const auto& float32=floats32[i/4]; layout->addWidget(float32,FLOATS32_ROW,float32->column(),1,float32->colSpan()); float32->show(); const auto& float64=floats64[i/8]; layout->addWidget(float64,FLOATS64_ROW,float64->column(),1,float64->colSpan()); float64->show(); } for(int row=ENTRIES_FIRST_ROW;row<ROW_AFTER_ENTRIES;++row) layout->itemAtPosition(row,LABELS_COL)->widget()->show(); layout->removeItem(hexSignOKCancelLayout); hexSignOKCancelLayout->setParent(nullptr); layout->addLayout(hexSignOKCancelLayout, ROW_AFTER_ENTRIES, ENTRIES_FIRST_COL, 1, numBytes); }
void QGridLayoutProto::removeItem(QLayoutItem *item) { QGridLayout *griditem = qscriptvalue_cast<QGridLayout*>(thisObject()); if (griditem) griditem->removeItem(item); }