Qt Windows Extrasについて
-
Qt Windows Extrasに関して悩んでおります。
Overviewによれば、QtWinExtrasでは以下の3つの機能が使えるとあります。
http://qt-project.org/doc/qt-5/qtwinextras-overview.htmlOverlay Icons and Progress Indicators
Jump Lists
Thumbnail Toolbar
このうち、Thumbnail Toolbarについては、所望の動作をさせることができたのですが、残りの2つについてはうまく動きません。
良い解決策がありましたら教えてください。まずOverlay Icons and Progress Indicatorsについて。
これは問題点が2点あります。
一つはsetOverlayIconとsetOverlayAccessibleDescriptionが動かないこと。
もう一つはProgress Indicatorsが、あるPCでは動くのに、別のPCでは動かないことです。
以下にコードを示します。
このコードはQMainWindowの派生クラスの中で記述しています。
処理が終わるまでbusy indicatorを表示する設定です。
Exampleを参考に作成したのですが、何が悪いのか分かりません。@
QWinTaskbarButton* tb = new QWinTaskbarButton();
tb->setWindow( windowHandle() );
tb->setOverlayAccessibleDescription( tr( "Processing..." ) );
tb->setOverlayIcon( QIcon( QPixmap( testIcon ) ) );
tb->progress()->setMinimum( 0 );
tb->progress()->setMaximum( 0 );
tb->progress()->setVisible( true );...Processing...
tb->progress()->setVisible( false );
tb->clearOverlayIcon();
delete tb;
@次にJump Listsについて。
Taskを追加したいのですがうまくいきません。Overviewに載っている以下のexample codeはコンパイルが通りません。
begin(), setKnownCategoryShown(), beginTasks(), addItem(), addLink(), commit()のいずれもQWinJumpListのメンバではありません。
Qt Windows Extrasのソースコードを確認したところ、これらはQWinJumpListPrivateのメンバであることが分かりました。@
QWinJumpList jumplist;
jumplist.begin();
jumplist.setKnownCategoryShown(QWinJumpList::RecentCategory);jumplist.beginTasks();
QWinJumpListItem *newProject = new QWinJumpListItem(QWinJumpListItem::Link);
newProject->setTitle(tr("Create new project"));
newProject->setFilePath(QDir::toNativeSeparators(QCoreApplication::applicationFilePath()));
newProject->setArguments(QStringList("--new-project"));
jumplist.addItem(newProject);jumplist.addLink(tr("Launch SDK Manager"), QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + "\sdk-manager.exe");
jumplist.commit();
@以下のトピックでも質問されているようですが、回答が与えられていません。
他には全く情報が出てきません。http://stackoverflow.com/questions/24084889/jumplist-wont-work-using-qwinjumplist
https://qt-project.org/forums/viewthread/37460
http://lists.qt-project.org/pipermail/interest/2014-January/010958.html
自前で下記のコードを書いてみましたが、Jump Listsは表示されません。
これ以上は自力で解決できそうにありません。@
QWinJumpList* jumpList = new QWinJumpList( this );
QList<QWinJumpListItem*> jumpListItem;
QStringList slArg[2];
slArg[0] << "--option0";
slArg[1] << "--option1";
QStringList slTitle;
slTitle << tr( "Test 1" )
<< tr( "Test 2" );
jumpListItem << new QWinJumpListItem( QWinJumpListItem::Link )
<< new QWinJumpListItem( QWinJumpListItem::Link );
for( int i = 0; i < 2; i++ ) {
jumpListItem[i]
->setFilePath( QDir::toNativeSeparators( qApp->applicationDirPath() +
"/test.exe" ) );
jumpListItem[i]->setIcon( QIcon( QPixmap( appIcon ) ) );
jumpListItem[i]->setDescription( tr( "Test" ) );
jumpListItem[i]->setArguments( slArg[i] );
jumpListItem[i]->setTitle( slTitle[i] );
jumpList->tasks()->addItem( jumpListItem[i] );
}
jumpList->tasks()->addSeparator();
jumpList->tasks()->setTitle( tr( "Tasks" ) );
jumpList->tasks()->setVisible( true );
@よろしくお願いします。
-
Qt Windows Extras にある Music Player Example は試されましたか。
まずはそちらを動かしてみてください。
http://qt-project.org/doc/qt-5/qtwinextras-musicplayer-example.htmlJump List をうまく動かすにはそちらの main.cpp で行っているレジストリへの登録が重要なようです。recent などは MIME Type が適切に登録されていれば自分で追加しなくても自動的に更新されるようです。
Overview の Example はひどいですね。こちらはAPIが開発中に変更されてから更新されていないように見えます。
動かして試してはいないのでAPIからの推測ですが、
begin(), beginTask() setKnownCategoryShown() などは public な API には無いので削除してください。
基本的には QWinJumpList に QWinJumpListCategory を登録して、そのカテゴリーに addItem() や addLink() する形になると思います。- Progress Indicators
順番が前後しましたが。
ぱっと見コード的に問題はなさそうですが、このコードの実行中はイベントループに戻っていますか。
「Processing」の間にイベントループに戻っていないのであれば QApplication::processEvents() を処理中に呼び出してみてください。