Results 1 to 5 of 5

Thread: QDirModel is not showing all volumes on Mac?

  1. #1
    Join Date
    Apr 2008
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question QDirModel is not showing all volumes on Mac?

    Hi friends,
    I have two volumes on my machine Mac Os and other is Data

    The finder View is :

    [IMG]file://localhost/Users/administrator/Desktop/Picture%201.png[/IMG]


    My program to show directory tree view is:

    Qt Code:
    1. int main(int argc, char* argv[])
    2. {
    3. QApplication app(argc,argv);
    4. QTreeView *tree= new QTreeView;
    5. QDirModel *dirModel = new QDirModel;
    6. tree->setModel(dirModel);
    7. tree->show();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 
    OutPut:

    [IMG]file://localhost/Users/administrator/Desktop/Picture%202.png[/IMG]



    Here it's not showing the Volume DATA only Showing Mac OS Volume.


    Can one tell how can i achieve it...


    Thanks,
    knrce
    Last edited by jpn; 14th May 2008 at 08:48. Reason: missing [code] tags

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDirModel is not showing all volumes on Mac?

    Start the dir model from dir /Volumes and enable hidden file ... not displayed on Finder
    after you can see all Volumes...

  3. #3
    Join Date
    Apr 2008
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Arrow Re: QDirModel is not showing all volumes on Mac?

    Hi,
    I created QDirModel as,

    Qt Code:
    1. QStringList list = QStringList() << "/Volumes";
    2. QDirModel *dirModel = new QDirModel(list, QDir::AllDirs | QDir::Hidden| QDir::NoDotAndDotDot,QDir::Name);
    3. tree->setModel(dirModel);
    4. tree->show();
    To copy to clipboard, switch view to plain text mode 

    now it is showing Volumes under /, but it is also showing all the Hidden files also like usr,etc,.vol ..........

    How to avoid them ....?

    Thanks,
    knrcse
    Last edited by jpn; 14th May 2008 at 13:40. Reason: changed [b] to [code] tags

  4. #4
    Join Date
    Oct 2007
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDirModel is not showing all volumes on Mac?

    Did you ever solved this problem. I have the same problem now. QDirModel does not show any external drives on Mac. Please, share your solution!

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDirModel is not showing all volumes on Mac?

    This is a piece ( QT4.2 ) of code to Open and read remode disk from apple + K

    if QDir can read ... model must read...
    otherwise submit a bug on trolltech


    Qt Code:
    1. void Setting_Gui::WebdavSetup()
    2. {
    3. label_webdav->setText(tr("Your OS Not Support Webdav"));
    4. QStringList diskremote;
    5. QString disksetting = Global_Config(APPLICATION_SETTING,"webdav_root");
    6. #if defined Q_WS_WIN
    7. /* netdrive webdrive mount */
    8. label_webdav->setText(tr("Window XP/2000 OS: Webdav Root (Radice)"));
    9. QString alfa ="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
    10. diskremote = alfa.split(",");
    11. webdav_root->clear();
    12. int loop= 0 - 1;
    13. int activeselected;
    14. QStringListIterator o(diskremote);
    15. while (o.hasNext()) {
    16. loop++;
    17. QString disker = o.next();
    18. QString diskeree = disker.append(":/");
    19. webdav_root->addItem(diskeree);
    20. if (disksetting == diskeree) {
    21. activeselected = loop;
    22. }
    23. }
    24. webdav_root->setEditable(false);
    25. webdav_root->setCurrentIndex(activeselected);
    26. #endif
    27. #if defined Q_WS_MAC
    28. /* apple + K */
    29. label_webdav->setText(tr("Mac OS: Mount Disk Webdav Root"));
    30. QString listdiron ="/Volumes/";
    31. webdav_root->addItem(disksetting);
    32. /* webdav_root->addItem(listdiron);*/
    33. QDir dir(listdiron);
    34. if (dir.exists()) {
    35. const QFileInfoList list = dir.entryInfoList();
    36. for (int i = 0; i < list.size(); i++)
    37. {
    38. fi = list.at(i);
    39. if (fi.isDir() && fi.fileName() != "." && fi.fileName() != "..") {
    40. QString disker = fi.absoluteFilePath();
    41. QString diskeree = disker.append("/");
    42. webdav_root->addItem(diskeree);
    43. }
    44. }
    45. }
    46. webdav_root->setEditable(false);
    47. #endif
    48.  
    49. #if defined Q_WS_X11
    50. /* http://www.webdav.org/cadaver/ */
    51. label_webdav->setText(tr("Linux OS: Mount Disk Webdav Root"));
    52. QString listdiron ="/mnt/";
    53. webdav_root->setEditable(true);
    54. webdav_root->addItem(disksetting);
    55. webdav_root->addItem(listdiron);
    56. #endif
    57.  
    58. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. about qt/embedded widgets showing in ARM platform
    By xianshuiren in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd December 2007, 05:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.