13,133
回編集
(→タイトルバー) |
|||
| 4行目: | 4行目: | ||
== タイトルバー == | == タイトルバー == | ||
==== アイコン ==== | |||
ウインドウのタイトルバーにアイコンを指定するには、<code>setWindowIcon</code>メソッドを使用する。<br> | ウインドウのタイトルバーにアイコンを指定するには、<code>setWindowIcon</code>メソッドを使用する。<br> | ||
<center> | <center> | ||
{| class="wikitable" style="background-color:#fefefe;" | {| class="wikitable" style="background-color:#fefefe;" | ||
|- | |- | ||
! style="background-color:# | ! style="background-color:#66CCFF;" | データ | ||
! style="background-color:# | ! style="background-color:#66CCFF;" | アイコンの設定例(QIconクラス) | ||
|- | |- | ||
| 標準画像 || QIcon Icon = style()->standardIcon(QStyle::SP_MediaPlay); | | style="text-align: center;" | 標準画像 || | ||
<syntaxhighlight lang="c++">QIcon Icon = style()->standardIcon(QStyle::SP_MediaPlay); | |||
QApplication::setWindowIcon(Icon);</syntaxhighlight> | |||
|- | |- | ||
| 標準カーソル || QCursor Cursor = Qt::WaitCursor; | | style="text-align: center;" | 標準カーソル || | ||
<syntaxhighlight lang="c++">QCursor Cursor = Qt::WaitCursor; | |||
if(!Cursor.pixmap().isNull()) | |||
{ | |||
QIcon Icon = QIcon(QPixmap(csr.pixmap())); | |||
QApplication::setWindowIcon(Icon); | |||
} | |||
</syntaxhighlight> | |||
|- | |- | ||
| | | style="text-align: center;" | リソースの指定 || | ||
<syntaxhighlight lang="c++"> | |||
QIcon Icon = QIcon(":/images/mouse.png"); | |||
QApplication::setWindowIcon(Icon); | |||
</syntaxhighlight> | |||
|- | |- | ||
| | | style="text-align: center;" | ファイルパスの指定 || | ||
<syntaxhighlight lang="c++"> | |||
QIcon Icon = QIcon("C:/temp/testimage.ico"); | |||
QApplication::setWindowIcon(Icon); | |||
</syntaxhighlight> | |||
|} | |} | ||
</center> | </center> | ||
<br> | |||
==== タイトルバーの非表示 ==== | |||
<code>setWindowFlags</code>メソッドを使用して、<code>Qt::FramelessWindowHint</code>フラグを設定することにより、ウインドウのタイトルバーが非表示になる。<br> | |||
この<code>Qt::FramelessWindowHint</code>フラグを使用すると、最大化/最小化ボタン、ウインドウの境界線、タイトルバーが非表示になる。<br> | |||
<br> | |||
したがって、このフラグを使用することにより、ウインドウ全体がカスタム外観になり、デフォルトのウインドウ機能が失われる。<br> | |||
また、必要に応じて、これらの機能を再実装することもできる。<br> | |||
<syntaxhighlight lang="c++"> | |||
#include <QGUIApplication> | |||
#include <QMainwindow> | |||
int main(int argc, char *argv[]) | |||
{ | |||
QGUIApplication a(argc, argv); | |||
QMainWindow Window; | |||
// タイトルバーを非表示にする | |||
Window.setWindowFlags(Qt::FramelessWindowHint); | |||
Window.show(); | |||
return a.exec(); | |||
} | |||
</syntaxhighlight> | |||
<br><br> | <br><br> | ||