Results 1 to 2 of 2

Thread: Cannot add new mimetype for a custom Qt Creator Plugin

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Cannot add new mimetype for a custom Qt Creator Plugin

    Hello,

    I am trying to develop an application on Qt Creator plugin Framework. I removed all the plugins except the coreplugin. Actually I want to implement a diagram editor which uses a custom xml format as the file format. I found a document "Writing-Qt-Creator-Plugins.pdf" and took it as a reference.

    So far I implemented all the interfaces(factory, editor, file,widget...). When I run Qt Creator my plugin is loaded succesfully(I can see it in plugins list) But the problem is I cannot load my specific file format(.mdv). I always get "Cannot open file..." error when I attempt.

    I created mimetypes.xml document:

    Qt Code:
    1. <?xml version="1.0"?>
    2. <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
    3. <mime-type type="application/d-editor">
    4. <sub-class-of type="application/xml"/>
    5. <comment>Diagram File</comment>
    6. <glob pattern="*.mdv"/>
    7. </mime-type>
    8. </mime-info>
    To copy to clipboard, switch view to plain text mode 

    loaded it:
    Qt Code:
    1. QString mimpath=":/diagramEditor.mimetypes.xml";
    2. mdb->addMimeTypes((const QString&)mimpath, &errMs);
    To copy to clipboard, switch view to plain text mode 


    I defined constants:
    Qt Code:
    1. const char * const C_DIAGRAMEDITOR_MIMETYPE = "application/d-editor";
    2. const char * const C_DIAGRAMEDITOR = "Diagram File";
    To copy to clipboard, switch view to plain text mode 

    and implemented IFile::mimeType(), IEditor::kind() and IEditorFactory::mimeTypes().

    Perhaps these may give some clue:
    in mimedatabase.cpp:
    *findByFile(QFileInfo&) method is returning false....
    *m_typeMimeTypeMap.contains(it.key()) always return false. I can debug that those guys contain "application/d-editor" and "application/xml"
    *
    Qt Code:
    1. Core::MimeType typ = mdb->findByType(QString(DiagramEditorConstants::Constants::C_DIAGRAMEDITOR_MIMETYPE));
    2. qDebug("File Type for application/d-editor = %s", qPrintable(typ.type()));
    To copy to clipboard, switch view to plain text mode 
    returns:
    File Type for application/d-editor = application/d-editor

    but
    Qt Code:
    1. Core::MimeType type1 = mdb->findByFile( QFileInfo("D:/qtcreator-truncated-build-desktop/YeniDiagram.mdv") );
    2. qDebug("File Type for sample.mdv = %s", qPrintable(type1.type()));
    To copy to clipboard, switch view to plain text mode 
    returns:
    File Type for sample.mdv =

    For 3 days I am trying to figure out what is going on; but i am stuck... Any idea, what may be the problem?

    Thanks in advance...
    Yigit

  2. #2
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Cannot add new mimetype for a custom Qt Creator Plugin

    Ok, i've figured out the problem. TextEditor.mimetypes.xml should also be added to mimemdatabase since my mimetype is a subclass of that. So by adding that mimetypes.xml, the problem is solved:

    Qt Code:
    1. QString mimpath=":/TextEditor.mimetypes.xml";
    2.  
    3. if(!mdb->addMimeTypes((const QString&)mimpath, &errMs))
    4. return false;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Need your help with designer plugin built with Creator
    By high_flyer in forum Qt Programming
    Replies: 4
    Last Post: 27th November 2010, 14:46
  2. Replies: 3
    Last Post: 13th September 2010, 21:14
  3. Replies: 1
    Last Post: 28th June 2010, 20:59
  4. Qt Creator doesn't load nested plugin
    By skepticalgeek in forum Qt Tools
    Replies: 0
    Last Post: 9th January 2010, 21:10
  5. add custom widgets to Qt Creator
    By yagabey in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2008, 17:26

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.