Unsolved QFileDialog sidebar on target device not visible
-
Hi, I have problems with a Qt Widget Application.
There is a difference in how the QFileDialog is displayed on my host computer and on my target device. On the taget device the sidebar with some urls isn’t visible. I’ve found out that there is a problem with the indexes of the Widgets in the QFileDialog. When I add a QButton to a specific place in QFileDialog then the position (0,0 --> see below) of the button on my Host Computer is as expected.
On target the position is different.
I guess there is a problem with the indexes. This would also explain the missing sidebar. Then if the position of the button on the target is (0,0) then the position of the sidebar would be negative. Does anyone had this problem before?Additional information:
- The Class CFileDialog inherits QFileDialog.
- I don’t use the native file dialog I use one from Qt.
- I hide some ToolButtons because I don’t need them, but there is no difference in behaviour when these lines are commented out.
Code:
CFileDialog* fileDialog = new CFileDialog(nullptr, caption, usbDir, "*.*"); fileDialog->setWindowTitle(caption); // enlarge buttons and list items fileDialog->setStyleSheet( "QPushButton{min-height: 40px; min-width: 200px;}" "QListView{font-size: 18px;}" "QListView::item{height: 50px;}" "QTreeView{font-size: 14px;}" "QTreeView::item{height: 50px;}" ); // use Qt design of dialog, and not the design from OS fileDialog->setOption(QFileDialog::DontUseNativeDialog, true); // make system read only fileDialog->setOption(QFileDialog::ReadOnly, true); // set the view (List or Detail) fileDialog->setViewMode(QFileDialog::Detail); // hide unnecessary tool buttons QToolButton* forwardButton = fileDialog->findChild<QToolButton *>("forwardButton"); if (forwardButton != nullptr){ forwardButton->hide(); } QToolButton* backButton = fileDialog->findChild<QToolButton *>("backButton"); if (backButton != nullptr){ backButton->hide(); } QToolButton* newFolderButton = fileDialog->findChild<QToolButton *>("newFolderButton"); if (newFolderButton != nullptr){ newFolderButton->hide(); } QToolButton* listModeButton = fileDialog->findChild<QToolButton *>("listModeButton"); if (listModeButton != nullptr){ listModeButton->hide(); } QToolButton* detailModeButton = fileDialog->findChild<QToolButton *>("detailModeButton"); if (detailModeButton != nullptr){ detailModeButton->hide(); } // add example button QGridLayout* gridLayout = fileDialog->findChild<QGridLayout *>("gridLayout"); gridLayout->addWidget(new QPushButton("USB"), 0,0); // remove file type selection box and add label QComboBox* fileTypeCombo = fileDialog->findChild<QComboBox *>("fileTypeCombo"); fileTypeCombo->hide(); // add short cuts for USB and NANDFlash QList<QUrl> urls; urls << QUrl::fromLocalFile("/USB_Disk") << QUrl::fromLocalFile("/NANDFlash"); fileDialog->setSidebarUrls(urls); // execute file dialog and get fileName QString filePath = QString(); if (fileDialog->exec()) { QStringList filePathList = fileDialog->selectedFiles(); if (!filePathList.empty()){ filePath = filePathList.at(0); } } // check for present file name if (!filePath.isNull()) { qDebug() << "FileDialog: selected file path: " << filePath.toUtf8(); } delete fileDialog; return filePath; }
Target Device
Platform: WinCE 7
Qt Version: 5.6.3 CommercialHost Computer
Platform: Win 10
Qt Version: 5.6.3 Commercial