I am making App. that includes Picture Editing, After Editing I want to save this Image As jpg file in my phone memory.. How can i do this?
Any help?
Thanks..
I don't have a Symbian device to check, but AFAIK it should be something like e.g.
QString filename = "c:\\folder\\filename.jpg";
bool success = mypixmap.save(filename);
assuming you have Symbian capabilities to write to the directory. The success will be true if the save was successful and false otherwise, and if necessary you can mess with the compression quality factor - here's the documentation.
I'm rusty on Symbian permissions, you might need WriteUserData to get this to work.
Related
I am trying to show a progress in the taskbar of the plasma desktop using the KDE Frameworks. In short, it want to do the same thing as dolphin, when it copies files:
I'm kinda stuck, because I don't even know where to get started. The only thing I found that could be useful is KStatusBarJobTracker, but I don't know how to use it. I could not find any tutorials or examples how to do this.
So, after digging around, and thanks to the help of #leinir, I was able to find out the following:
Since Plasma 5.6 KDE supports the Unitiy DBus Launcher-API, which can be used, for example, to show progress
I found a post on AskUbuntu that explains how to use the API with Qt
The real problem is: This only works, if you have a valid desktop file in one of the standard locations! You need to pass the file as parameter of the DBus message to make it work.
Based on this information, I figured out how to use it and created a GitHub repository, that supports cross platform taskbar progress, and uses this API for the linux implementation.
However, here is how to do it anyways. It should work for KDE Plasma and the Unity desktop, maybe more (haven't tried any others):
Create a .desktop file for your application. For test purpose, this can be a "dummy" file, that could look like this:
[Desktop Entry]
Type=Application
Version=1.1
Name=MyApp
Exec=<path_to>/MyApp
Copy that file to ~/.local/share/applications/ (or wherever user specific desktop files go on your system)
In your code, all you need to do is execute the following code, to update the taskbar state:
auto message = QDBusMessage::createSignal(QStringLiteral("/com/example/MyApp"),
QStringLiteral("com.canonical.Unity.LauncherEntry"),
QStringLiteral("Update"));
//you don't always have to specify all parameters, just the ones you want to update
QVariantMap properties;
properties.insert(QStringLiteral("progress-visible"), true);// enable the progress
properties.insert(QStringLiteral("progress"), 0.5);// set the progress value (from 0.0 to 1.0)
properties.insert(QStringLiteral("count-visible"), true);// display the "counter badge"
properties.insert(QStringLiteral("count"), 42);// set the counter value
message << QStringLiteral("application://myapp.desktop") //assuming you named the desktop file "myapp.desktop"
<< properties;
QDBusConnection::sessionBus().send(message);
Compile and run your application. You don't have to start it via the desktop file, at least I did not need to. If you want to be sure your application is "connected" to that desktop file, just set a custom icon for the file. Your application should show that icon in the taskbar.
And thats basically it. Note: The system remembers the last state when restarting the application. Thus, you should reset all those parameters once when starting the application.
Right, so as it turns out you are right, there is not currently a tutorial for this. This reviewboard request, however, shows how it was implemented in KDevelop, and it should be possible for you to work it out through that :) https://git.reviewboard.kde.org/r/127050/
ps: that there is no tutorial now might be a nice way for you to hop in and help out, by writing a small, self contained tutorial for it... something i'm sure would be very much welcomed :)
I'm trying to understand how I can generate a waveform from an audio (or video) file to display to the user.
I've been googling around for quite a while now and can't determine if this is even possible in Qt without using something like FFmpeg. I've seen all of these classes: QMediaPlayer, QMediaContent, QMediaResource, QAudioProbe and experimented with the Qt Media Player Example but am just not seeing where I can access the actual audio buffer.
So I have 2 questions:
Is what I want to do even possible without 3rd party libraries?
If it is possible, can some kind soul outline what I need to read and understand in order to access the audio data
I have tried the suggestions from this question (Audio visualization with QMediaPlayer) but the result of audioProbe->setSource(player) is always false and the method processBuffer never gets called.
audioProbe = new QAudioProbe(this);
bool success = audioProbe->setSource(player);
qDebug() << success;
connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(processBuffer(QAudioBuffer)));
Update: Adding some additional detail in the hope of clarifying things.
For testing/learning I am using the Media Player Example which ships with Qt, so it is set up correctly with Q_OBJECT etc.
For audio, I tested with both .mp3 and .wav files. FWIW, the player example won't play video for some reason (.mp4, .avi were tested)
The player in the code is QMediaPlayer – which inherits from QMediaObject. The example code for the Player class is here. I added my code (in original comment above) right after the player is instantiated. I also tried adding it once media is loaded.
I tried declaring my slot first as private, then as public – either way, it is never called.
Frustrating that such a simple thing is so hard.
Going the "no external library" route will likely just lead to more of a headache and more work than is necessary. The other advantage of going with an established library is you won't be bound to one file format, as not all formats store their data the same way. If the audio format is uncompressed (wav or other) you can read the header until you get to the data chunk. An answer to this question here details this in C. You should be able to get an idea for the file format from this to apply it to another language.
You will want to understand how many channels are in the wav file, bit depth, and also the sampling rate before you can do anything worthwhile with the data. All this info can be grabbed from the header.
It turns out that QAudioProbe is not supported on OSX – the platform I am working on. Took quite a while (a "Qt while. . .") to ferret that info out so I am posting it here explicitly.
See this document for full details: Qt 5.5.0 Multimedia Backends
I am programming on the Windows 7 platform using Qt 4.8.4, Qt Mobility 1.2 and C++. I am attempting to record audio from the front jack and save it to a file in mp3 format. I have the program working with the LAME encoder, but the file is being saved as WAV.
It appears that I have no control over the container type, which is defaulting to PCM/WAV.
Here are the QAudioEncoderSettings I am using:
QAudioEncoderSettings settings;
settings.setCodec("audio/mpeg");
settings.setSampleRate(boxValue(ui->sampleRateBox).toInt());
settings.setBitRate(boxValue(ui->bitrateBox).toInt());
settings.setQuality(QtMultimediaKit::EncodingQuality(ui->qualitySlider->value()));
settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
QtMultimediaKit::ConstantQualityEncoding :
QtMultimediaKit::ConstantBitRateEncoding);
QString container = "audio/x-mp3";
capture->setEncodingSettings(settings, QVideoEncoderSettings(), container);
A post recording conversion is not an option, as the files may become quite large, and the probability that the process would be ended before the conversion was complete is quite high.
Thank you for any help provided.
You can try Qt Media Encoding Library for that - http://qt-project.org/forums/viewthread/29117/
I wrote a tool which was originally thought for analyzing hard disc images. Now I'm trying to use this tool for live analyzis of computer systems, means my tool tries to access the physical drive.
I implemented my tool in QT accessing the images using the QFile class. Instead of images I hand over the physical drive, under windows it is \.\PHYSICALDRIVE0.
I was wondering first I didnt get any errors, I can open the device, I can seek, get the position, almost everything. The only thing I have problems with is retrieving the drive size with size().
Some code example:
QFile file( "\\.\PHYSICALDRIVE0" );
file.open( QIODevice::ReadOnly );
file.size(); //returns 0
I'm not too deep into QT, probably this is some easy thing. I would like to thank everybody who has an idea what is the reason.
thanks in advance!
QFileInfo may be able to help you out. It sounds like opening a read only file at that part of windows partition is allowed maybe even if it doesn't exist. There might be a chance that the call of GetLastError() may give more information why a file size of zero was returned.
With QFileInfo, you can check to make sure it exists before it opens.
You may end up needing some platform specific calls to be able to work with Physical Drives:
Volume to physical drive
It looks like there may be some example code of looking at partitions with PartMod on SourceForge.
As a side note of querying sizes of file folders, I thought it had to be cached somewhere by the operating system, or had to be calculated at the time of the query in many cases. I know it seems like that happens when looking at folder properties in Windows or Get Info on OSX.
Also, looking at the Volume to physical drive answers, there is a field there for the extent length. I think this is what you are looking for.
Hope that helps.
I have a Qt desktop application that works on Linux and Windows. At some point I'm hoping to port it to MacOS X and other *nix systems too.
My problem is that, a part of the application has a functionality that allows users to drag and drop files into, and out from an archive. The UI is kinda like that of WinZip or similar GUI based archivers. But Qt's drag and drop system wants the data to be prepared when the user starts dragging files from the archive.
What I currently do is, extract the dragged files to a temporary location, and supply those file names as data. But it's undesirable because extracting deep directory trees take a good amount of time, and it causes the GUI to freeze during that time. It would be nice if I could do that operation when the user decides to drop the files, not when he/she starts to drag. Unfortunately Qt docs don't say anything about this.
I know how to achieve this using Windows API, and I'm pretty sure that most systems have a way to do that too. But I want to avoid writing platform specific code as much as possible.
Is there a Qt way to achieve that? Am I missing something?
I may be misunderstanding, but I think what you want to do is supply enough information in a QMimeData for the QDrag you create that you can find the files in the archive after the user drops it without having to extract them first. So, if your code on the drop end doesn't know which archive the files have come from, you need to supply the path to the archive in your mime data, too.
The drag starts as a message:
"I'm dragging Archive1:FileA, Archive1:FileB" but no file extraction.
It ends on the other end by interpreting the message and then extracting the files. I'd probably set up some kind of simple ICD for both sides of the message transfer. If you can only drag from one archive at a time, maybe a string list with the first element being the archive and following ones being the files:
QStringList list;
list << archivePath;
list << fileName1;
list << fileName2;
QByteArray ba;
QDataStream stream(&ba);
stream << list;
QMimeData* mime = new QMimeData;
mime->setData("yourType", ba);
I hope this helps!