本文整理汇总了C++中QWidget::deleteLater方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::deleteLater方法的具体用法?C++ QWidget::deleteLater怎么用?C++ QWidget::deleteLater使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::deleteLater方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testWaitEndedWithDefaultConstructor
void WaitForWindowTest::testWaitEndedWithDefaultConstructor() {
WaitForWindow waitForWindow;
waitForWindow.setWindowObjectName("theName");
waitForWindow.setActive(true);
//WaitFor* must be registered in order to be used with QSignalSpy
int waitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*");
QSignalSpy waitEndedSpy(&waitForWindow, SIGNAL(waitEnded(WaitFor*)));
QWidget* otherWindow = new QWidget(mMainWindow);
otherWindow->setObjectName("otherName");
otherWindow->setWindowFlags(Qt::Window);
otherWindow->show();
otherWindow->deleteLater();
QVERIFY(!waitForWindow.conditionMet());
QCOMPARE(waitEndedSpy.count(), 0);
QWidget* window = new QWidget(mMainWindow);
window->setObjectName("theName");
window->setWindowFlags(Qt::Window);
window->show();
window->deleteLater();
QVERIFY(waitForWindow.conditionMet());
QCOMPARE(waitEndedSpy.count(), 1);
QVariant argument = waitEndedSpy.at(0).at(0);
QCOMPARE(argument.userType(), waitForStarType);
QCOMPARE(qvariant_cast<WaitFor*>(argument), &waitForWindow);
}
示例2: startVisualCapture
// creation of a new capture in GUI mode
void Controller::startVisualCapture(const uint id, const QString &forcedSavePath) {
if (!m_captureWindow) {
QWidget *modalWidget = nullptr;
do {
modalWidget = qApp->activeModalWidget();
if (modalWidget) {
modalWidget->close();
modalWidget->deleteLater();
}
} while (modalWidget);
m_captureWindow = new CaptureWidget(id, forcedSavePath);
//m_captureWindow = new CaptureWidget(id, forcedSavePath, false); // debug
connect(m_captureWindow, &CaptureWidget::captureFailed,
this, &Controller::captureFailed);
connect(m_captureWindow, &CaptureWidget::captureTaken,
this, &Controller::captureTaken);
#ifdef Q_OS_WIN
m_captureWindow->show();
#else
m_captureWindow->showFullScreen();
//m_captureWindow->show(); // Debug
#endif
} else {
emit captureFailed(id);
}
}
示例3: initForm
void frmClients::initForm(WId w_ID,int fl){
if (fl==1){
ui->closeFrame->setHidden(true);
ui->ClientTabs->setVisible(true);
selClients = true;
}
else{
ui->closeFrame->setVisible(true);
ui->ClientTabs->setHidden(true);
selClients = false;
}
if (w_ID != 0x0){
QWidget *frm = find(w_ID);
frm->deleteLater();
}
clSqlQueryModel *model = new clSqlQueryModel();
model->setQuery("select FIO, nom_tel, DATE_R, ID, DEL, POL FROM clients");
model->setHeaderData(0,Qt::Horizontal,QObject::tr("ФИО"));
model->setHeaderData(1,Qt::Horizontal,QObject::tr("Тел."));
model->setHeaderData(2,Qt::Horizontal,QObject::tr("Дата рожд."));
model->setHeaderData(3,Qt::Horizontal,QObject::tr("ID"));
model->setHeaderData(4,Qt::Horizontal,QObject::tr("DEL"));
model->setHeaderData(5,Qt::Horizontal,QObject::tr("POL"));
ui->tableView->setModel(model);
ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
ui->tableView->setColumnHidden(3,true);
ui->tableView->setColumnHidden(4,true);
ui->tableView->setColumnHidden(5,true);
}
示例4: removeChatView
void BufferWidget::removeChatView(BufferId id) {
QWidget *view = _chatViews.value(id, 0);
if(!view) return;
ui.stackedWidget->removeWidget(view);
view->deleteLater();
_chatViews.take(id);
}
示例5: addTeam
void TeamSelector::addTeam(Team* team)
{
//FIXME: this fails if there is a team with the same port
Session::getInstance().addTeamCommAgent(team);
teams.push_back(team);
teamsMap[team->number] = team;
std::map<unsigned short, int>::iterator i = teamPages.find(team->number);
TeamView* teamPage = new TeamView(this, team);
int index = -1;
if(i != teamPages.end())
{
index = i->second;
QWidget* oldPage = widget(index);
removeTab(index);
oldPage->deleteLater();
insertTab(index, teamPage, fromString("Team: "+team->name));
}
else
{
index = addTab(teamPage, fromString("Team: "+team->name));
}
teamViews[team->number] = teamPage;
teamPages[team->number] = index;
}
示例6: insertTab
int ComboTabBar::insertTab(int index, const QIcon &icon, const QString &text, bool pinned)
{
if (pinned) {
index = m_pinnedTabBar->insertTab(index, icon, text);
}
else {
index = m_mainTabBar->insertTab(index - pinnedTabsCount(), icon, text);
if (tabsClosable()) {
QWidget* closeButton = m_mainTabBar->tabButton(index, closeButtonPosition());
if ((closeButton && closeButton->objectName() != QLatin1String("combotabbar_tabs_close_button")) || !closeButton) {
// insert our close button
insertCloseButton(index + pinnedTabsCount());
if (closeButton) {
closeButton->deleteLater();
}
}
}
index += pinnedTabsCount();
}
updatePinnedTabBarVisibility();
tabInserted(index);
setMinimumWidths();
return index;
}
示例7: setMode
void DolphinView::setMode(Mode mode)
{
if (mode == m_mode) {
return; // the wished mode is already set
}
QWidget* view = (m_iconsView != 0) ? static_cast<QWidget*>(m_iconsView) :
static_cast<QWidget*>(m_detailsView);
if (view != 0) {
m_topLayout->remove(view);
view->close();
view->deleteLater();
m_iconsView = 0;
m_detailsView = 0;
}
m_mode = mode;
createView();
ViewProperties props(m_urlNavigator->url());
props.setViewMode(m_mode);
emit signalModeChanged();
}
示例8: setTabItemCount
void TabBar::setTabItemCount(const QString &tabName, const QString &itemCount)
{
const int i = tabIndex(tabName, *this);
if (i == -1)
return;
QWidget *tabCountLabel = tabButton(i, QTabBar::RightSide);
if ( itemCount.isEmpty() ) {
if (tabCountLabel) {
tabCountLabel->deleteLater();
setTabButton(i, QTabBar::RightSide, nullptr);
}
} else {
if (!tabCountLabel) {
tabCountLabel = new QLabel(this);
tabCountLabel->setObjectName("tab_item_counter");
setDefaultTabItemCounterStyle(tabCountLabel);
setTabButton(i, QTabBar::RightSide, tabCountLabel);
}
tabCountLabel->setProperty("text", itemCount);
tabCountLabel->adjustSize();
}
updateTabStyle(i);
}
示例9: addHardwareParametersGroup
void ConfigObjectDialog::addHardwareParametersGroup(QLayout *parent) {
list<SpmcPeripheral*> peripherals = object->getPeripherals();
QVBoxLayout* layout = new QVBoxLayout();
QWidget* widget = new QWidget();
QFormLayout* paramsLayout = new QFormLayout();
widget->setLayout(paramsLayout);
QVBoxLayout* pinLayout = new QVBoxLayout();
for (list<SpmcPeripheral*>::iterator i = peripherals.begin(); i != peripherals.end(); i++) {
if (!((*i)->getParameters().empty())) {
addParameters(paramsLayout, (*i)->getParameters());
}
map<string, list<PeripheralPort*> > ports = (*i)->getPorts();
for (map<string, list<PeripheralPort*> >::iterator i = ports.begin(); i != ports.end(); i++) {
addPortsGroup(pinLayout, i->first, i->second);
}
}
addGroup(layout, "Pins", pinLayout);
QWidget* tpWidget = new QWidget();
QFormLayout* tpLayout = new QFormLayout();
tpWidget->setLayout(tpLayout);
addParameters(tpLayout, object->getTimestampPinParameters());
pinLayout->addWidget(tpWidget);
if (!paramsLayout->isEmpty()) {
layout->insertWidget(0, widget);
} else {
widget->deleteLater();
}
addGroup(parent, "Hardware Parameter", layout);
}
示例10: setUpCleanupPage
void MainWindow::setUpCleanupPage()
{
for (int i = 0; i < m_ui.stackedWidget->count(); ++i) {
QWidget *w = m_ui.stackedWidget->widget(i);
m_ui.stackedWidget->removeWidget(w);
w->deleteLater();
}
QVBoxLayout *lay = new QVBoxLayout;
lay->addStretch();
QLabel *logo = new QLabel();
logo->setPixmap(KIcon("chakra-shiny").pixmap(128));
lay->addWidget(logo);
QLabel *l = new QLabel("Cleaning up...");
lay->addWidget(l);
lay->addStretch();
QWidget *w = new QWidget;
w->setLayout(lay);
m_ui.stackedWidget->addWidget(w);
m_ui.previousButton->setVisible(false);
m_ui.nextButton->setVisible(false);
m_ui.abortButton->setVisible(false);
}
示例11: closeDialog
void DialogController::closeDialog()
{
QWidget *dialog = m_dialog;
m_dialog = nullptr;
m_widget = nullptr;
if(!dialog)
return;
QRect geom = dialog->geometry();
int w = geom.width() + m_dialogOffsetLeft;
QPropertyAnimation *animation = new QPropertyAnimation(dialog, "geometry");
animation->setStartValue(visibleGeometry(dialog));
animation->setEndValue(hiddenGeometry(dialog));
animation->setDuration(300);
animation->setEasingCurve(QEasingCurve::OutExpo);
animation->start();
connect(animation, &QPropertyAnimation::finished, [=]{
animation->deleteLater();
dialog->close();
dialog->deleteLater();
});
emit dialogClosed();
}
示例12: currentWebView
WebView *TabWidget::webView(int index) const
{
QWidget *widget = this->widget(index);
if (WebViewWithSearch *webViewWithSearch = qobject_cast<WebViewWithSearch*>(widget)) {
return webViewWithSearch->m_webView;
} else if (widget) {
// optimization to delay creating the first webview
if (count() == 1) {
TabWidget *that = const_cast<TabWidget*>(this);
that->setUpdatesEnabled(false);
LocationBar *currentLocationBar = qobject_cast<LocationBar*>(m_locationBars->widget(0));
bool giveBackFocus = currentLocationBar->hasFocus();
m_locationBars->removeWidget(currentLocationBar);
m_locationBars->addWidget(new QWidget());
that->newTab();
that->closeTab(0);
QWidget *newEmptyLineEdit = m_locationBars->widget(0);
m_locationBars->removeWidget(newEmptyLineEdit);
newEmptyLineEdit->deleteLater();
m_locationBars->addWidget(currentLocationBar);
currentLocationBar->setWebView(currentWebView());
if (giveBackFocus)
currentLocationBar->setFocus();
that->setUpdatesEnabled(true);
that->m_swappedDelayedWidget = true;
return currentWebView();
}
}
return 0;
}
示例13: updateLegend
void PlotMarkerLegend::updateLegend(QwtLegend* legend) const
{
if ( legend == NULL )
return;
if ( legend && testItemAttribute( QwtPlotItem::Legend ) && symbol() && symbol()->style() != QwtSymbol::NoSymbol )
{
QWidget *lgdItem = legend->find( this );
if ( lgdItem == NULL )
{
lgdItem = legendItem();
if ( lgdItem )
legend->insert( this, lgdItem );
}
LegendItem *l = qobject_cast<LegendItem *>( lgdItem );
if ( l )
l->setIdentifierSize( symbol()->boundingSize() );
}
QWidget *lgdItem = legend->find( this );
if ( testItemAttribute( QwtPlotItem::Legend ) )
{
LegendItem *label = qobject_cast<LegendItem *>( lgdItem );
if ( label )
{
// paint the identifier
const QSize sz = label->identifierSize();
QPixmap identifier( sz.width(), sz.height() );
identifier.fill( Qt::transparent );
QPainter painter( &identifier );
painter.setRenderHint( QPainter::Antialiasing, testRenderHint( QwtPlotItem::RenderAntialiased ) );
drawLegendIdentifier( &painter, QRect( 0, 0, sz.width(), sz.height() ) );
painter.end();
const bool doUpdate = label->updatesEnabled();
if ( doUpdate )
label->setUpdatesEnabled( false );
label->setText( title() );
label->setIdentifier( identifier );
label->setItemMode( legend->itemMode() );
if ( doUpdate )
label->setUpdatesEnabled( true );
label->update();
}
}
else
{
if ( lgdItem )
{
lgdItem->hide();
lgdItem->deleteLater();
}
}
}
示例14: tabCloseRequested
void PopupChatWindow::tabCloseRequested(int tab)
{
QWidget *widget = ui.tabWidget->widget(tab);
if (widget) {
widget->deleteLater();
}
}
示例15: openPanel
void SidebarWidget::openPanel(const QString &identifier)
{
QWidget *widget = NULL;
if (identifier.isEmpty())
{
widget = NULL;
}
else if (identifier == QLatin1String("bookmarks") || identifier == QLatin1String("cache") || identifier == QLatin1String("config") || identifier == QLatin1String("cookies") || identifier == QLatin1String("history") || identifier == QLatin1String("transfers"))
{
Window *window = new Window(false, NULL, this);
window->setUrl(QLatin1String("about:") + identifier, false);
connect(window, SIGNAL(requestedOpenUrl(QUrl,OpenHints)), this, SLOT(openUrl(QUrl,OpenHints)));
widget = window;
}
else if (identifier.startsWith(QLatin1String("web:")))
{
Window *window = new Window(false, NULL, this);
window->setUrl(identifier.section(':', 1, -1));
connect(window, SIGNAL(requestedOpenUrl(QUrl,OpenHints)), this, SLOT(openUrl(QUrl,OpenHints)));
widget = window;
}
if (m_currentWidget)
{
QWidget *currentWidget = m_currentWidget;
m_currentWidget = NULL;
layout()->removeWidget(currentWidget);
currentWidget->deleteLater();
}
if (m_buttons.contains(m_currentPanel) && m_buttons[m_currentPanel])
{
m_buttons[m_currentPanel]->setChecked(false);
}
if (widget)
{
layout()->addWidget(widget);
if (m_buttons.contains(identifier) && m_buttons[identifier])
{
m_buttons[identifier]->setChecked(true);
}
}
m_currentPanel = identifier;
m_currentWidget = widget;
updateSize();
}