I am trying to get the data from an image dragged directly from a browser to my Qt app. I have the following code:
void MyView::dropEvent( QDropEvent* event )
{
QGraphicsView::dropEvent( event );
if ( event->mimeData()->hasImage() )
{
QImage image = qvariant_cast<QImage>( event->mimeData()->imageData() );
...
This works fine with Firefox (Windows/Mac), Safari (Mac) and IE (Windows). But QMimeData::hasUrl() returns false for Chrome on both Windows and Mac.
On further investigation Qt expects image data in MIME format "application/x-qt-image". It seems that Chrome doesn't provide this. Is there a workaround for Chrome? I haven't been able to find anything.
Related
I am building an app with AVKit and MediaPlayer and want to show a cover in the control center. Using this code didn't worked for me:
if let image = UIImage(named: "myCover") {
nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { size in
return image
}
}
First, I thought that downloading the UI Image failed, but then i realised that this issue also happend when using a locally saved image.
By the way: Setting up the player (pause/play/background mode) worked fine.
I am using iOS 16 and Xcode 14.0.1.
where is your nowPlayingInfo coming from ?
In my process I declare a new dictionary with titles and stuff
then I process my image later with async download using
MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPMediaItemPropertyArtwork] = artwork
I mean if you directly set it in the default Center is it still not showing ?
With a Javascript snippet in Chrome devtools, I can use Shiny.setInputValue('input',0) while my Shiny app is running to reset the value of an actionButton. It works well and I only need that one line.
However, I would like to use it inside my app with shinyjs.
Here is what I have in my .js script (Note that yes, shinyjs is properly set up and I am using it for many other functions throughout my app).
shinyjs.zeroInput = function(inputID) {
Shiny.setInputValue(inputID, 0);
};
I have button A which once clicked needs to reset button B to zero:
observeEvent(input$mybuttonA, {
shinyjs::js$zeroInput("mybuttonB")
})
This does not work and the chrome Javascript console outputs this when button A is clicked:
Note that using Shiny.setInputValue("mybuttonB",0) in the Chrome Javascript console works like a charm. What is going on?
I figured out what was wrong.
All I needed to do was convert the javascript function argument into a string:
shinyjs.zeroInput = function(inputID) {
Shiny.setInputValue(String(inputID), 0);
};
I'm having a problem trying to disable Firefox extensions programmatically. Right now, I'm modifying the extension.json file , changing the 2 parameters , active and userDisabled , but without any success. Despite the fact that in the extension menu it appears to be disabled , the icon of extensions still appear in the toolbar and I can see that the extensions still work. Is there a way to make this work using C++ ?
That won't work you have to use AddonManager.jsm to change the property like this:
Cu.import('resource://gre/modules/AddonManager.jsm');
AddonManager.getAddonByID('Profilist#jetpack', function(addon) { //id of the addon
console.info('addon:', addon);
addon.userDisabled = false; //set to true to enable it
});
I am writing a little file/archives explorer and got an issue with interaction between qt-based app and Skype chat window on Windows platform only.
When I try to drag-drop file (provided by QDrag with file-urls mime data) from my app to skype chat window, file is sent twice. The same I’ve got when tried to modify one of Qt drag-drop examples.
Skype version is 5.10.0.116. Bug is reproducible on Qt versions 4.7.3, 4.8.1, 4.8.3.
EDIT:
Have tried drag-drop interactions between several apps
My app -> Explorer = ok
My app -> Notepad++ = ok (displays content of file only in one tab)
My app -> WinRar = ok (creates archive with
only one file)
My app -> TotalCommander = ok
My app -> ICQ = ok (only one file is sent)
My app -> Clementine (Qt based music player) = ok (only one file
is added to playlist)
Explorer -> Skype = ok
But
My app -> Skype - file is sent twice
Clementine -> Skype - file is sent twice
EDIT2:
Also, qt-created mime data differs from created by explorer.
Qt:
0 "text/uri-list" "file:///C:/Users/user/Pictures/myfile.ext"
1 "application/x-qt-windows-mime;value="UniformResourceLocatorW""
"..." (I've replaced QByteArray contents with ellipsis)
Explorer:
0 "application/x-qt-windows-mime;value="Shell IDList Array"" "..."
1 "application/x-qt-windows-mime;value="UsingDefaultDragImage""
"..."
2 "application/x-qt-windows-mime;value="DragImageBits"" "..."
3 "application/x-qt-windows-mime;value="DragContext"" "..."
4 "application/x-qt-windows-mime;value="DragSourceHelperFlags""
"..."
5 "application/x-qt-windows-mime;value="InShellDragLoop"" "..."
6 "text/uri-list" "file:///C:/Users/user/Pictures/myfile.ext"
I see, it’s not a problem if Qt, it’s wrong mime data processing on Skype side. Along with “text/uri-list”, Qt provides “UniformResourceLocatorW” value with the same data (i cant deny it, it is added a much deeper, than Qt user can get). And Skype processes both values – “text/uri-list” and “UniformResourceLocatorW”, causing sending the same file twice.
I wonder how to open a link in a default user browser using Qt (that would open it across all platforms (Win Mac Lin))?
In the doc: QDesktopServices
http://doc.qt.io/qt-4.8/qdesktopservices.html#openUrl
bool QDesktopServices::openUrl ( const QUrl & url ) [static]
Opens the given url in the appropriate Web browser for the user's desktop environment, and returns true if successful; otherwise returns false.
You can try this code
QString link = "http://www.google.com";
QDesktopServices::openUrl(QUrl(link));
Read QDesktopServices and QUrl to get further information.
you are looking for openUrl() in the desktop services class
http://qt-project.org/doc/qt-4.8/QDesktopServices.html