c++ - Is there such thing as a MIME type for all audio and video like "audio/*" and "video/*"? -


i'm writing application in which, in drag , drop, want accept audio , video types.

this code in qt5 drop in widget:

void dragdropframe::dragenterevent(qdragenterevent* evt) {     if (frame_type == frame_type::droppable)     {         if (evt->mimedata()->hasformat("audio/*"))         {             evt->acceptproposedaction();         }         else             evt->ignore();     }     else         evt->ignore(); } 

yet "audio/*" not work. widget not accept file. have "if-else" possibile audio , video mime-types or there quicker solution?

no, there no general-purpose mime type that.

the evt tell specific mime type(s) holds. can substring/pattern matching see if types match looking for, eg:

void dragdropframe::dragenterevent(qdragenterevent* evt) {     if (frame_type == frame_type::droppable)     {         qstringlist formats = evt->mimedata()->formats();         if (!formats.filter("audio/").empty() ||             !formats.filter("video/").empty())         {             evt->acceptproposedaction();             return;         }     }      evt->ignore(); } 

alternatively:

void dragdropframe::dragenterevent(qdragenterevent* evt) {     if (frame_type == frame_type::droppable)     {         qregexp regex("\\b(audio|video)/*", qt::caseinsensitive, qregexp::wildcard);         if (!evt->mimedata()->formats().filter(regex).empty())         {             evt->acceptproposedaction();             return;         }     }      evt->ignore(); } 

Comments