void EventQueueWindowState::onLeaveState() { WindowStateWithMenu::onLeaveState(); QVBoxLayout *verticalLayout = dynamic_cast<QVBoxLayout*>(wsw.layout()); Q_ASSERT(verticalLayout != 0); verticalLayout->removeWidget(wsw.viewer()); verticalLayout->removeWidget(bottomWidget); verticalLayout->removeWidget(&wsw); delete verticalLayout; bottomWidget->hide(); }
// Use for modeless or modal dialogs. // (Use show_widget instead, if displaying this widget NOT as a dialog.) // void MTDetailEdit::dialog(MTDetailEdit::DetailEditType theType, bool bIsModal/*=false*/) { FirstRun(theType); // This only does something the first time it's run. (Otherwise this does nothing.) // ------------------------------------------- RefreshRecords(); // ------------------------------------------- if (bIsModal) { QDialog theDlg; theDlg.setWindowTitle(this->windowTitle()); // theDlg.installEventFilter(this); QVBoxLayout * pLayout = new QVBoxLayout; pLayout->addWidget(this); theDlg.setLayout(pLayout); theDlg.setWindowFlags(Qt::Tool); // A hack so it will show the close button. theDlg.exec(); pLayout->removeWidget(this); } else { this->installEventFilter(this); show(); setFocus(); } // ------------------------------------------- }
void MultiViewWidget::splitView(Qt::Orientation orient, ContainerWidget *container) { QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout *>(container->parent()); QSplitter *split = qobject_cast<QSplitter *>(container->parent()); if (!widgetLayout) if (container->parent() == this) widgetLayout = qobject_cast<QVBoxLayout *>(layout()); if (widgetLayout) { QSplitter *splitter = new QSplitter(orient, this); widgetLayout->removeWidget(container); widgetLayout->addWidget(splitter); splitter->addWidget(container); container = createContainer(); splitter->addWidget(container); QList<int> sizes; int s = Qt::Horizontal ? splitter->size().width() / 2 : splitter->size().height() / 2; sizes << s << s; splitter->setSizes(sizes); } else if (split) { QSplitter *splitter = new QSplitter(orient, this); int idx = split->indexOf(container); splitter->addWidget(container); container = createContainer(); splitter->addWidget(container); split->insertWidget(idx, splitter); QList<int> sizes; int s = Qt::Horizontal ? splitter->size().width() / 2 : splitter->size().height() / 2; sizes << s << s; splitter->setSizes(sizes); } }
// NOTE: Unlike QMainWindow::addToolBar, we only allow one // fixed-size undockable menu bar at top of the dock layout. void TMainWindow::setMenuWidget(QWidget *menubar) { if (menubar) { QVBoxLayout *vlayout = static_cast<QVBoxLayout *>(layout()); // If necessary, remove current menu bar if (m_menu && m_menu != menubar) vlayout->removeWidget(m_menu); vlayout->insertWidget(0, menubar); } }
void SettingsWidget::updateAddresses(const Protos::Common::Interface& interfaceMess, QWidget* container) { QVBoxLayout* layout = container->findChild<QVBoxLayout*>(); if (!layout) { layout = new QVBoxLayout(container); QMargins margins = layout->contentsMargins(); margins.setTop(3); layout->setContentsMargins(margins); } QList<QRadioButton*> addressesNotUpdated = container->findChildren<QRadioButton*>(); for (int i = 0; i < interfaceMess.address_size(); i++) { const QString& addresseName = Common::ProtoHelper::getStr(interfaceMess.address(i), &Protos::Common::Interface::Address::address); for (QListIterator<QRadioButton*> j(container->findChildren<QRadioButton*>()); j.hasNext();) { QRadioButton* addressButton = j.next(); if (addressButton->text() == addresseName) { addressesNotUpdated.removeOne(addressButton); if (interfaceMess.address(i).listened()) addressButton->setChecked(true); goto nextAddress; } } { // Address not found -> add a new one. QRadioButton* newAddressButton = new QRadioButton(addresseName, container); this->ui->grpAddressesToListenTo->addButton(newAddressButton); if (interfaceMess.address(i).listened()) newAddressButton->setChecked(true); layout->addWidget(newAddressButton); } nextAddress: ; } // Remove the non-existant addresses. for (QListIterator<QRadioButton*> i(container->findChildren<QRadioButton*>()); i.hasNext();) { QRadioButton* current = i.next(); if (addressesNotUpdated.contains(current)) { layout->removeWidget(current); this->ui->grpAddressesToListenTo->removeButton(current); delete current; } } }
void CollapsibleGroup::removeGroup(int ix, QVBoxLayout *layout) { QMutexLocker lock(&m_mutex); QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout()); if (vbox == NULL) return; for (int i = m_subWidgets.count() - 1; i >= 0 ; i--) { vbox->removeWidget(m_subWidgets.at(i)); layout->insertWidget(ix, m_subWidgets.at(i)); m_subWidgets.at(i)->decoframe->setObjectName("decoframe"); m_subWidgets.at(i)->removeFromGroup(); } m_subWidgets.clear(); }
void DCCSliderAnnotated::setSlider(DCCSlider *slider) { if (slider == m_slider) return; if (!m_slider) { QVBoxLayout *la = qobject_cast<QVBoxLayout*>(layout()); if (la) { la->removeWidget(m_slider); } m_slider->deleteLater(); } m_slider = slider; }
void FluushOption::FileListSent(QList<FluushFileInfo> &list) { QVBoxLayout *lay = ui->history; for(int i = 0 ; i < lay->count() ; i++) { QWidget* it = lay->itemAt(i)->widget(); lay->removeWidget(it); it->deleteLater(); } for(QList<FluushFileInfo>::iterator i = list.begin() ; i != list.end() ; i++) { ThumbWidget *wid= new ThumbWidget(ui->apiKey->text(), (*i).id, (*i).url, (*i).name, net, this); lay->addWidget(wid); } }
void SettingsWidget::updatePropertyWidgetSemantics(PropertyWidgetQt* widget) { Property* prop = widget->getProperty(); QVBoxLayout* listLayout = static_cast<QVBoxLayout*>(widget->parentWidget()->layout()); int layoutPosition = listLayout->indexOf(widget); PropertyWidgetQt* propertyWidget = static_cast<PropertyWidgetQt*>(PropertyWidgetFactory::getPtr()->create(prop).release()); if (propertyWidget) { prop->deregisterWidget(widget); listLayout->removeWidget(widget); listLayout->insertWidget(layoutPosition, propertyWidget); prop->registerWidget(propertyWidget); connect(propertyWidget, SIGNAL(updateSemantics(PropertyWidgetQt*)), this, SLOT(updatePropertyWidgetSemantics(PropertyWidgetQt*))); propertyWidget->initState(); } else {
void MultiViewWidget::removeView() { ContainerWidget *container = qobject_cast<ContainerWidget *>(sender()); if (container) { QSplitter *splitter = qobject_cast<QSplitter *>(container->parent()); if (splitter && splitter->count() == 2) { // Get its parent, and insert the other widget into it, delete this widget. QSplitter *splitterParent = qobject_cast<QSplitter *>(splitter->parent()); QWidget *moveWidget = splitter->widget(0); if (moveWidget == container) moveWidget = splitter->widget(1); setActiveWidget(moveWidget); if (splitterParent) { int idx = splitterParent->indexOf(splitter); splitterParent->insertWidget(idx, moveWidget); splitter->deleteLater(); } else if (splitter->parent() == this) { // No more splits - back to single view widget. QVBoxLayout *layoutParent = qobject_cast<QVBoxLayout *>(layout()); if (layoutParent) { layoutParent->addWidget(moveWidget); layoutParent->removeWidget(splitter); splitter->deleteLater(); } } } else if (container->parent() == this) { // Delete the current container, and create the option container. QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(layout()); container->deleteLater(); ContainerWidget *newContainer = createContainer(); vLayout->addWidget(newContainer); setActiveWidget(newContainer); } } }
void MTDetailEdit::dialog(MTDetailEdit::DetailEditType theType, bool bIsModal/*=false*/) { if (m_bFirstRun) { m_bFirstRun = false; // ------------------------------------------- ui->tableWidget->setColumnCount(2); ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); // ------------------------------------------- ui->tableWidget->horizontalHeader()->resizeSection(0, 5); // ------------------------------------------- ui->tableWidget->horizontalHeader()->setStretchLastSection(true); ui->tableWidget->verticalHeader()->setDefaultSectionSize(60); ui->tableWidget->verticalHeader()->hide(); ui->tableWidget->horizontalHeader()->hide(); // ------------------------------------------- ui->tableWidget->setContentsMargins(10,0,0,0); // ------------------------------------------- ui->tableWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding); // ---------------------------------- m_pTabWidget = new QTabWidget; // ---------------------------------- m_pTabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_pTabWidget->setContentsMargins(5, 5, 5, 5); // ---------------------------------- QWidget * pTab1 = new QWidget; // ---------------------------------- pTab1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pTab1->setContentsMargins(5, 5, 5, 5); // ---------------------------------- m_pTabWidget->addTab(pTab1, tr("Details")); // ------------------------------------------- // Instantiate m_pDetailPane to one of various types. // m_Type = theType; switch (m_Type) { case MTDetailEdit::DetailEditTypeNym: m_pDetailPane = new MTNymDetails(this, *this); break; case MTDetailEdit::DetailEditTypeContact: m_pDetailPane = new MTContactDetails(this, *this); break; case MTDetailEdit::DetailEditTypeServer: m_pDetailPane = new MTServerDetails(this, *this); break; case MTDetailEdit::DetailEditTypeAsset: m_pDetailPane = new MTAssetDetails(this, *this); break; case MTDetailEdit::DetailEditTypeAccount: m_pDetailPane = new MTAccountDetails(this, *this); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(DefaultAccountChanged(QString, QString)), m_pMoneychanger, SLOT (setDefaultAccount(QString, QString))); // ------------------------------------------- // connect(m_pDetailPane, SIGNAL(cashBalanceChanged()), // m_pMoneychanger, SLOT (onCashBalanceChanged())); // // ------------------------------------------- // connect(m_pDetailPane, SIGNAL(acctBalanceChanged()), // m_pMoneychanger, SLOT (onAcctBalanceChanged())); // // ------------------------------------------- break; default: qDebug() << "MTDetailEdit::dialog: MTDetailEdit::DetailEditTypeError"; return; } // ------------------------------------------- m_pDetailPane->SetOwnerPointer(*this); // ------------------------------------------- m_pDetailLayout = new QVBoxLayout; m_pDetailLayout->addWidget(m_pDetailPane); m_pDetailPane ->setContentsMargins(1,1,1,1); m_pDetailLayout->setContentsMargins(1,1,1,1); // ---------------------------------- pTab1->setLayout(m_pDetailLayout); // ---------------------------------- int nCustomTabCount = m_pDetailPane->GetCustomTabCount(); if (nCustomTabCount > 0) { for (int ii = 0; ii < nCustomTabCount; ii++) { QWidget * pTab = m_pDetailPane->CreateCustomTab(ii); // ---------------------------------- if (NULL != pTab) { pTab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pTab->setContentsMargins(5, 5, 5, 5); QString qstrTabName = m_pDetailPane->GetCustomTabName(ii); m_pTabWidget->addTab(pTab, qstrTabName); } // ---------------------------------- } } // ----------------------------------------------- QGridLayout * pGridLayout = new QGridLayout; pGridLayout->addWidget(m_pTabWidget); pGridLayout->setContentsMargins(0,0,0,0); m_pTabWidget->setTabPosition(QTabWidget::South); // ---------------------------------- ui->widget->setContentsMargins(1,1,1,1); // ---------------------------------- ui->widget->setLayout(pGridLayout); // ---------------------------------- } // first run. // ------------------------------------------- RefreshRecords(); // ------------------------------------------- // if (m_map.size() < 1) // on_addButton_clicked(); // ------------------------------------------- if (bIsModal) { QDialog theDlg; theDlg.setWindowTitle(this->windowTitle()); // theDlg.installEventFilter(this); QVBoxLayout * pLayout = new QVBoxLayout; pLayout->addWidget(this); theDlg.setLayout(pLayout); theDlg.setWindowFlags(Qt::Tool); // A hack so it will show the close button. theDlg.exec(); pLayout->removeWidget(this); } else { this->installEventFilter(this); show(); setFocus(); } // ------------------------------------------- }