PDA

View Full Version : Qt and windows 7 new Api



ManicQin
5th January 2010, 11:09
I would like to integrate the new Windows 7 api into my App.
(The new task bar)

Will I have any problem working with a visual studio 10 Dll and QT Creator?
(Is there any other way to do it?)

yhanks

squidge
5th January 2010, 14:27
QT Creator uses GCC, so it's not going to be easy to work with a Visual Studio DLL. You'll be better of using Visual Studio and the appropriate Qt plug-in. That way you'll get access to the latest API, library files, and include files, which will not be present with Qt Creator.

wysota
5th January 2010, 14:44
Let's make one thing clear. Your application is not linked against Qt Creator so the latter doesn't pose any dependencies on the application. You can also use MSVC with Creator insted of GCC, that's no problem. The fact that Qt SDK includes both Qt Creator and MinGW is meaningless, they are two separate components.

faldzip
5th January 2010, 14:56
I'm using QtCreator with VisualStudio 2005 Toolchain on Windows 7 x64 without any problems (apps are compiled for 32 bit). I don't where is the option for changing toolchain in QtCreator - I just installed it without MinGW and it set itself to use my previously installed Visual Studio Compiler and that's it :]

I don't know what do you understand under "integration" with Windows7. My apps are shown on the taskbar, but if you want access some of it's special feature's (like in IE - you can choose any tab separately on the taskbar) I think you need to use some native Windows API.

ManicQin
5th January 2010, 15:18
Thanks everybody, apparently I haven't explained my self.

fatjuicymole you understood my question, thanks for your answer.

wysota thanks, I'm aware of the difference between the components but I didn't know that I can instruct QTCreator to use MSVC as compiler.

When I've downloaded the framework I needed to choose the compiler I'm intending to use, I downloaded the QTCreator bundled with the mingw.
So now if I want to work with msvc I need to redownload the framework (now for msvc) and redirect the QTCreator to a new compiler
(and even maybe to a new framework directory ... I dont want to overwrite the QT libs for mingw libs)
Or as fatjuicymole said I'll just use visual studio and link it to the qt libs...

faldżip like you said, I was talking about using the task bar new features, especially the progress notification... I've seen tutorials about how to work them with visual studio 10... (apparently the sdk is already included)

I think that in the end because this is not such an important issue of what I'm working on I'll just throw the progress into a file\socket and read it via a .Net agent... the point is having fun with QT and not producing something commercial.

Will QT ever support this kind of features? so platform dependent?
thanks everybody!

wysota
5th January 2010, 15:34
wysota thanks, I'm aware of the difference between the components but I didn't know that I can instruct QTCreator to use MSVC as compiler.
You just tell it to use nmake instead of make (which is probably auto-detected anyway).


Or as fatjuicymole said I'll just use visual studio and link it to the qt libs...
You will still need to download Qt for MSVC.

bender86
12th January 2010, 14:23
faldżip like you said, I was talking about using the task bar new features, especially the progress notification... I've seen tutorials about how to work them with visual studio 10... (apparently the sdk is already included)

You have to request the system for a proper task bar using the function RegisterWindowMessage (http://msdn.microsoft.com/en-us/library/ms644947(VS.85).aspx), then you wait for a response in the member function QWidget::winEvent . Then, you can create the task bar and use it.
Maybe you could understand better this small example I wrote.
Have also a look at the functions ITaskbarList3::SetProgressState (http://msdn.microsoft.com/en-us/library/dd391697(VS.85).aspx) and ITaskbarList3::SetProgressValue (http://msdn.microsoft.com/en-us/library/dd391698(VS.85).aspx).
Unfortunately I do not know much about using other features of new task bars.


TEMPLATE = app

LIBS += User32.lib
LIBS += Ole32.lib

HEADERS += ProgressDialog.h
SOURCES += ProgressDialog.cpp


#include <QDialog>
#include <QTimer>

#include <windows.h>
#include <shobjidl.h>

class ProgressDialog : public QDialog
{
Q_OBJECT
public:
ProgressDialog(QWidget *parent = 0);

protected:
bool winEvent(MSG * message, long * result);

private:
void setupProgressBar();

private slots:
void updateProgress();

private:
QTimer timer;
int progress;
int totalProgress;
bool canUseTaskBar;
UINT taskBarCreatedMessage;
ITaskbarList3 * taskbar;
};



#include "ProgressDialog.h"

#include <shobjidl.h>
#include <Objbase.h>

#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ProgressDialog d;
d.show();
return a.exec();
}

ProgressDialog::ProgressDialog(QWidget *parent) :
QDialog(parent)
{
this->progress = 0;
this->totalProgress = 1000;
this->canUseTaskBar = false;

this->timer.setInterval(10);
this->connect( & this->timer, SIGNAL(timeout()), this, SLOT(updateProgress()));

// Request task bar.
this->taskBarCreatedMessage = RegisterWindowMessage(L"TaskbarButtonCreated");
}

bool ProgressDialog::winEvent(MSG * message, long * result)
{
if (message->message == this->taskBarCreatedMessage)
{
HRESULT hr = CoCreateInstance(CLSID_TaskbarList,
0,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS( & this->taskbar));
if (hr == S_OK) {
this->canUseTaskBar = true;

// Start progress.
this->setupProgressBar();
this->timer.start();
} else {
this->canUseTaskBar = false;
// Error.
}
*result = hr;
return true;
}

return false;
}

void ProgressDialog::setupProgressBar()
{
if (this->canUseTaskBar) {
// Select the progress bar type.
// One of these:

// No progress bar.
// this->taskbar->SetProgressState(this->winId(), TBPF_NOPROGRESS);

// Unknown progress.
// this->taskbar->SetProgressState(this->winId(), TBPF_INDETERMINATE);

// Normal progress (green bar).
this->taskbar->SetProgressState(this->winId(), TBPF_NORMAL);

// Paused (yellow bar).
// this->taskbar->SetProgressState(this->winId(), TBPF_PAUSED);

// Error (red bar).
// this->taskbar->SetProgressState(this->winId(), TBPF_ERROR);
}
}

void ProgressDialog::updateProgress()
{
if (this->canUseTaskBar) {
// Set progress.
this->taskbar->SetProgressValue(this->winId(), this->progress, this->totalProgress);

progress++;
}
}

ManicQin
12th January 2010, 14:40
Great Post!
Thank you very much.

raven-worx
6th February 2011, 23:04
i needed the same features and found some interesting links which may be helpful :p

http://www.strixcode.com/q7goodies/
($49-35$)

http://www.msec.it/blog/?p=118
free, GPL, compiles even with mingw32