-
Bug
-
Resolution: Duplicate
-
P2: Important
-
4.5.2
-
None
Run the following example and do this:
1) When the applications is started, click on the second tab untitled 'Table View'
2) Click on the first tab untitled 'List View'
3) Click on the button 'Open Native'
4) When the dialog is opened, click on Cancel button
Then the content of the list is empty where it should not.
#include <QtGui>
class QTextEdit;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
private slots:
void openNativeDialog();
void openNoNativeDialog();
private:
QTabWidget * m_tabWidget;
};
#include "main.moc"
MainWindow::MainWindow()
{
m_tabWidget = new QTabWidget(this);
QListWidget * pageList = new QListWidget(this);
pageList->addItem("item1");
pageList->addItem("item2");
QTableWidget * pageTable = new QTableWidget(this);
pageTable->insertColumn(0);
pageTable->insertColumn(1);
pageTable->insertRow(0);
pageTable->insertRow(1);
m_tabWidget->addTab(pageList, QIcon(), "List View");
m_tabWidget->addTab(pageTable, QIcon(), "Table View");
setCentralWidget(m_tabWidget);
QAction * openNative = new QAction("Open Native", this);
QAction * openNoNative = new QAction("Open No Native", this);
connect(openNative, SIGNAL(triggered()), this, SLOT(openNativeDialog()));
connect(openNoNative, SIGNAL(triggered()), this, SLOT(openNoNativeDialog()));
QToolBar * fileToolBar = addToolBar(tr("File"));
fileToolBar->addAction(openNative);
fileToolBar->addAction(openNoNative);
}
void MainWindow::openNativeDialog()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QString::null, tr("Image Files (*.png *.jpg *.bmp)"));
}
void MainWindow::openNoNativeDialog()
{
QFileDialog fOpen(this, tr("Open Image"), QString::null, tr("Image Files (*.png *.jpg *.bmp)"));
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow mainWin;
mainWin.show();
return app.exec();
}