Isavailable is not a member of QSound - c++

I want to compile some old QT project with QT 5.2.1 and have many trouble, one of which is QSound problem:
if(!QSound::isAvailable()) {
ui.grpSounds->setEnabled(false);
ui.grpSounds->setTitle(tr("Sounds (Not Available)"));
}
error:
'isAvailable' is not a member of 'QSound'
will anyone help me? I am completely newbie with Qt.
Thank you.

If you want to notify the user whether or not sounds can be played then your best bet is QAudioDeviceInfo. You can query for available input or output devices using the static method
QList<QAudioDeviceInfo> QAudioDeviceInfo::availableDevices(QAudio::Mode mode)
For instance you can replace QSound::isAvailable() by
!QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).isEmpty()
Edit:
QSound was part of the gui module, but now is part of the multimedia module (which make more sense). You need take a look at the changes in multimedia modules from Qt4 to Qt5 for more info. You may also want to look at QSoundEffect, which seems to have a richer API

According to class reference, Qt 5.2 don't have Sound::isAvailable() static method http://qt-project.org/doc/qt-5/qsound.html
It was in Qt4.8

Related

QML running with Qt for Embedded System on uclinux?

I only write QML app with Qt 5.1.1 running on Mac & Windows.
Anyone know what's the version of Qt for Embedded System integrated in the uclinux?
Do the Qt on uclinux support QML? Do I need to re-implement the UI with Qt widgets in C++ to run it on the uclinux?
First and foremost, please do not ask several subquestions in a question.
Anyone know what's the version of Qt for Embedded System integrated in the uclinux?
There is no such a thing. Qt 5 is meant to be well supported for embedded, too, without external third-party projects.
That being said, you may ask Digia about their embedded plans, like Boot2Qt and so on.
Do the Qt on uclinux support QML?
That is the wrong question around. The correct question is whether Qt/QML suppports uclinux. I do not think this will work off-hand, no. You will probably start writing a custom mkspecs file for your scenario and fix lots of issues.
Do I need to re-implement the UI with Qt widgets in C++ to run it on the uclinux?
That would probably be even worse as they are having a lot of overhead in terms additional layer. What I would suggest is to forget about QML for now, and try to bring up a simple screen with QScreen.
As stated, I do not think even that will work off-hand, but if you are enthusiastic, you could get it work.
Since Qt 5 has a hard dependency on the standard library these days, your first task is to get that building againt your mmu-free uclibc. There was some discussion about that here.
But honestly, you may be better off with some lightweight gui framework that supports framebuffer for rendering. Qt is big and not properly tested on minimal systems.

VST2.x GUI How does it work?

Although I know how to create a VST plugin today, I still don't understand the GUI part of it.
I've been playing around with Steinbergs samples and what I can see is that they are using some default sliders in the exapmles, but am I supposed to use these when designing my own and apply some graphics to them? Or should I create my own completly? How should I think around the GUI approach to make the GUI code also work for both PC and MAC later on?
I've been searching my rearbehind off but can't find anything about these questions anywhere. Please give my a lead or guide me to the light so I can grow my hair back.
How should I think around the GUI approach to make the GUI code also
work for both PC and MAC later on?
If that is your ultimate goal, then I strongly suggest you check out the JUCE library. The plugin wrappers are very good and it is completely cross-platform.

Android UI in C++

I know this is kind of reinventing the wheel, but how hard would it be to implement an android user interface with C++? Is it hard to create things like buttons, and to handle touch screen events like button clicks? Is this feasible and if so, how would you go about doing it?
Take a look at Necessitas, its a Qt port for android which seems to work pretty well.
It might still be in Alpha or Beta stage though, so it will depends on how "serious" your project is. But that proves for sure that one can use plain C++ to build a complete application, not only libraries.
You can always use the JNI to go back up into java to get UI components on the screen. If you set it up to be little more than an API, you can simulate actually doing it in native code. NVidea has some good samples on how to do this: http://developer.nvidia.com/tegra-resources This library code isn't doing it for UI components, but is for various other things (sound, resources, etc). and the idea should work for UI components too.
Also, this project supposedly supports the entire sdk in c++, and I would imagine it's doing it the same way. I don't know how up to date it is, as I haven't actually used it: http://code.google.com/p/android-cpp-sdk/
You can use JNIpp to create wrapper for activity and all UI classes you are interested in.
Take a look at HelloJNIpp sample, it features native Activity, native custom drawn View and a button.
Spoiler:
void MainActivity::OnCreate(const jni::LObject& bundle) {
Activity::OnCreate(bundle);
SetContentView(R::GetLayout("main"));
FindViewById(R::GetID("changeColor"))->
SetOnClickListener(*this,&MainActivity::ChangeColor);
}

wxwidgets vs gtkmm with my requirements

I'm implementing a GUI program (a cards game) in gtkmm (at the moment). I want that my program runs well at least under Windows and Linux (GTK). Mac OS X would be a plus, although not required. Although I'm using gtkmm, I have some concerns with it.
More concretely:
Lack of support for connecting signals at runtime.
The API for treeview is horrible in the sense that you need to make your own classes
in c++ code every tie you have a new Treemodel.
These two things get a lot in my way when implementing GUI code. My questions are, if I switch to wxwidgets:
1.- Is it possible to connect signals at runtime?
2.- Is the ListCtrl API from Wxwidgets comfortable to use in your opinion?
3.- Is there a decent gui builder (preferably free, but not required) in which I don't have to connect signals by hand in c++ code? This is quite important to keep controller and view code separated.
4.- Is there an alternative to wxwidgets which is better and looks good under gtkmm, besides working on Windows. I'd rather not use qt with its preprocessing step
Thanks in advance.
It is possible.
ListCtrl if just fine to use, and you will maybe find some nicer alternative (UltimateListCtrl, wxGrid...).
wxFormBuilder.
Not that I know of.

How to take screenshot in Mac OS X using Cocoa or C++

How to take screenshot programmically of desktop area in Mac OS X ?
Two interesting options I have seen, but yet to use professionally, are the screencapture utility and a MacFuse demo.
The screencapture utility has been around since 10.2, according to the man page, and could be linked to a Cocoa application by use of NSTask.
The MacFuse demo worked by creating a new screenshot each time a folder was opened, or something like that. The idea being you could write a quick script to access the image when you needed it, without having to have the script actually run on that machine.
But seriously, Apple has some other sample code called "Son of Grab" which uses the new CGWindow API which is pretty awesome.
http://developer.apple.com/samplecode/SonOfGrab/
One way of going about doing this would be to use NSTask in conjuction with the 'screencapture' command line command.
For example:
NSTask *theProcess;
theProcess = [[NSTask alloc] init];
[theProcess setLaunchPath:#"/usr/sbin/screencapture"];
// use arguments to set save location
[theProcess setArguments:#"blahblah"];
[theProcess launch];
The you could open up the file wherever you told it to be saved, process it, and then delete it as needed. Obviously stopgap, but it would work.
If you're fine with Leopard compatibility, there's a very powerful new CGWindow API that will let you grab screen shots, window shots, or composites of any range of window layers.
http://developer.apple.com/samplecode/SonOfGrab/
Qt includes an example screenshot app in examples\desktop\screenshot. Qt works on a range of platforms, including MacOSX.
http://trolltech.com/products/qt/
The following might be helpful if you are attempting to accomplish this with C++ or python. Also, this would be even more helpful in the case that you want your programmatic method to be cross-platform portable. (Windows, Linux, Mac osx, and even beyond)
An earlier response mentions QT.
In the same way that QT will allow you to capture and save a screenshot, so does another "competing" framework, namely wxWidgets. wxWidgets is a C++ framework, but it also provides python bindings via wxPython.
To read more, use the following link, search the book for wxScreenDC and choose "Page 139" from the list of pages that match the search:
http://books.google.com/books?id=CyMsvtgnq0QC&vq="accessing+the+screen+with+wxScreendc"
If you consider REALbasic, this is extremely easy to do with RB and the MBS Plugins. I've just written an application that does timed screenshots using RB and the MBS Plugins. You can read about it here: http://tektalkin.blogspot.com/2008/08/screenaudit-for-mac-osx.html