@@ -1711,9 +1711,11 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
1711
1711
// Create the SQL dialog: this might become an independent class dialog in the future, for now
1712
1712
// we are still prototyping the features that this dialog will have.
1713
1713
1714
- QgsDialog dialog;
1715
- dialog.setObjectName ( QStringLiteral ( " SQLCommandsDialog" ) );
1716
- dialog.setWindowTitle ( tr ( " %1 — Execute SQL" ).arg ( item->name () ) );
1714
+ QMainWindow *dialog = new QMainWindow ();
1715
+ dialog->setObjectName ( QStringLiteral ( " SQLCommandsDialog" ) );
1716
+ dialog->setWindowTitle ( tr ( " %1 — Execute SQL" ).arg ( item->name () ) );
1717
+ QgsGui::enableAutoGeometryRestore ( dialog );
1718
+ dialog->setAttribute ( Qt::WA_DeleteOnClose );
1717
1719
1718
1720
// If this is a layer item (or below the hierarchy) we can pre-set the query to something
1719
1721
// meaningful
@@ -1737,11 +1739,9 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
1737
1739
tableName, 10 );
1738
1740
}
1739
1741
1740
- QgsGui::enableAutoGeometryRestore ( &dialog );
1741
- QgsQueryResultWidget *widget { new QgsQueryResultWidget ( &dialog, conn2.release () ) };
1742
+ QgsQueryResultWidget *widget { new QgsQueryResultWidget ( nullptr , conn2.release () ) };
1742
1743
widget->setQuery ( sql );
1743
- widget->layout ()->setContentsMargins ( 0 , 0 , 0 , 0 );
1744
- dialog.layout ()->addWidget ( widget );
1744
+ dialog->setCentralWidget ( widget );
1745
1745
1746
1746
connect ( widget, &QgsQueryResultWidget::createSqlVectorLayer, widget, [ item, context ]( const QString &, const QString &, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions & options )
1747
1747
{
@@ -1757,9 +1757,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
1757
1757
}
1758
1758
1759
1759
} );
1760
- dialog.exec ();
1761
-
1762
-
1760
+ dialog->show ();
1763
1761
} );
1764
1762
menu->addAction ( sqlAction );
1765
1763
}
0 commit comments