Results 1 to 10 of 10

Thread: SubClass QFileIconProvider (from QDirModel) not compile....

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: SubClass QFileIconProvider (from QDirModel) not compile....

    Quote Originally Posted by wysota View Post
    QFileIconProvider is not a QObject, so you can't use Q_OBJECT with it.

    if i remove Q_OBJECT can compile but not running...! and not display my icons..

    i put Q_OBJECT why? on scribus apps having....

    http://stuff.mit.edu/afs/athena/soft...ustomfdialog.h

    maybe is qt3 ... i dont no..
    Qt Code:
    1. #include "scribusapi.h"
    2.  
    3. /**
    4.   *@author Franz Schmid
    5.   */
    6. class SCRIBUS_API ImIconProvider : public QFileIconProvider
    7. {
    8. Q_OBJECT
    9. QPixmap imagepm;
    10. QPixmap docpm;
    11. QPixmap pspm;
    12. QPixmap pdfpm;
    To copy to clipboard, switch view to plain text mode 



    i put so... and default icon is here ...

    modeluser = new QDirModel();
    modeluser->setIconProvider(new ImIconProvider());
    modeluser->setResolveSymlinks(false);
    usertree->setModel(modeluser);
    modeluser->setSupportedDragActions(Qt::CopyAction);
    usertree->setDragEnabled(true);
    usertree->setRootIndex(modeluser->index(ustart));

    i can drag file direct to desktop (on model or outsite model) or viceversa .. is running rename delete , open file on clicked all running .. only the icon is fake....










    Qt Code:
    1. class ImIconProvider : public QFileIconProvider
    2. {
    3. public:
    4. QStringList file_image;
    5. QStringList file_text;
    6. QStringList file_other;
    7. ImIconProvider();
    8. ~ImIconProvider() {};
    9. QIcon icon( const QFileInfo & fi );
    10. QIcon icon( IconType type );
    11. };
    12.  
    13. ImIconProvider::ImIconProvider()
    14. {
    15. file_image.clear();
    16. file_text.clear();
    17. file_other.clear();
    18. file_image << "eps" << "gif" << "png" << "jpg" << "jpeg" << "xpm" << "tif" << "tiff" << "bmp" << "pbm" << "pgm" << "ppm" << "xbm" << "xpm" << "psd";
    19. file_text << "txt" << "cpp" << "h" << "dat" << "conf" << "ini" << "rtf" << "fos" << "xml" << "htm" << "html" << "css" <<"js";
    20. file_other << "pdf" << "doc" << "pdf" << "exe" << "rar" << "bz" << "tar" << "gz" << "zip";
    21. }
    22.  
    23. QIcon ImIconProvider::icon(const QFileInfo &fi)
    24. {
    25. qDebug() << "### filename " << fi.fileName(); /* nothing comming!! */
    26.  
    27. const QString ext = fi.suffix().toLower();
    28. if (file_image.contains(ext)) {
    29. return QIcon("image.png");
    30. } else if (file_image.contains(ext)) {
    31. return QIcon("text.png");
    32. } else if (file_image.contains(ext)) {
    33. return QIcon("other.png");
    34. } else {
    35. return QIcon("other.png");
    36. }
    37. /* end icon s*/
    38. }
    39.  
    40. QIcon ImIconProvider::icon( IconType type )
    41. {
    42. return QIcon("other.png");
    43. }
    To copy to clipboard, switch view to plain text mode 

  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: SubClass QFileIconProvider (from QDirModel) not compile....

    QFileDialog display correct all icon (QDirModel NO!) .... so if you take QFileIconProvider from QFileDialog

    and done to model this is not running ... i suppose a BUG!


    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6.  
    7. QDirModel model;
    8. model.setIconProvider(QFileDialog::iconProvider());
    9. QTreeView tree;
    10. tree.setModel(&model);
    11. tree.setWindowTitle(QObject::tr("Dir View"));
    12. tree.resize(640, 480);
    13. tree.show();
    14.  
    15. return app.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    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: SubClass QFileIconProvider (from QDirModel) not compile....

    i found bugs....
    http://www.trolltech.com/developer/t...ntry&id=139120
    now build & 4.3.0 and take easy a break..

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.