Qtでウィンドウの表示範囲変更するの簡単だった

参考にしたのはここらへん↓
月の杜工房 - Qt ウィンドウスタイル
日記帳だ! with Tux on Libserver :: 丸いQtウイジェット


Qtをwindowsで使う方法

Visual Studioを使わないでQt書く情報が少なすぎて苦労した

流れとしては

  1. コード書く
  2. qmake
  3. nmake

Visual Studioを使わない場合nmakeを使う必要がある
mingwのmakeでもいけるらしいけどcygwinでmakeしたらエラーでた、何故だ

前準備

コマンドプロンプト

"c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"

ってやるとnmake使えるようになるらしいよ

コード書く

#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QWidget window;
    window.resize(400, 120);

    QPushButton hello("hellllooo", &window);
    hello.setFont(QFont("Times", 60, QFont::Bold));
    hello.setGeometry(50, 10, 300, 100);
    QObject::connect(&hello, SIGNAL(clicked()), &app, SLOT(quit()));

    window.setMask(QRegion(QRect(50,10,300,100),QRegion::Rectangle));
    window.show();
    return app.exec();
}

setMaskで表示する範囲を指定できるんですねー

qmake

qmake -project
qmake

qmakeは隙を生じぬ二段構え

nmake

nmakeの情報少なすぎワロタ
Visual Studioのディレクトリに入ってるよ
前述した通り前準備しないと使えないよ

結果


はいな