Qt 5.1.0 の変更点(補足)

Qt 5.1.0 がリリース されました。5.1.0 の主な変更点は 5.1.0 アルファ版のリリース記事 に書いていますが、そこにない変更点について補足しておきます。

OpenGL

Qt 5.1 の OpenGL については別に 記事 を作成してありますが、その後 KDAB の blog に記事が追加されています。

Qt 5.0 までは OpenGL ES 2.0 との互換性を確保するためか Vertex Shader と Fragment Shader しかシェーダーを扱えませんでしたが、Qt 5.1 では OpenGL 3 以降に登場したシェーダーが使えるようになりました。

  • Geometry Shaders (requires OpenGL 3.2)
  • Tessellation Control and Tessellation Evaluation Shaders (requires OpenGL 4.0)
  • Compute Shaders (requires OpenGL 4.3)

ポーティングガイド

いまさらながら C++ API changes にいくつかの項目が追記されています。重要なものもありますので気をつけてください。以下に 5.0 から追記された項目だけをリストアップします。

  • Qt Core: QAbstractItemModel::createIndex method now only provides the void* and quintptr overloads, making calls with a literal 0 (createIndex(row, col, 0)) ambiguous. Either cast (quintptr(0)) or omit the third argument(to get the void* overload).
  • Qt Core: QUrl no longer has functions that handle individual query items and query delimiters, such as addQueryItem() and queryPairDelimiter(). These have been moved to the new QUrlQuery class.
  • Qt Core: Qt::WFlags is deprecated, use Qt::WindowFlags instead. This typedef dates from the Qt 1 days, and such abbreviations are not current Qt style.
  • Qt GUI: QPen now has a default width of 1 instead of 0. Thus, it is no longer cosmetic by default.
  • Qt GUI: QDesktopServices::storageLocation() and QDesktopServices::displayName() are replaced by QStandardPaths::storageLocation() and QStandardPaths::displayName() respectively. They are now in the Qt Core module.
  • Qt GUI: QPixmap::grabWindow() and QPixmap::grabWidget() are removed. Use QScreen::grabWindow() instead.
  • Qt Widgets: QApplication::setGraphicsSystem() is removed as the introduction of QPA made it redundant.
  • Qt Print Support: Support for printing PostScript files has been removed.
  • Qt Test: QTest::qWaitForWindowShown() is replaced with QTest::qWaitForWindowExposed().

なお、上記には含まれていませんが、Qt4 の QDesktopServices と Qt5 の QStandardPaths では DataLocation が異なるという問題も報告されています。

5.1.0 には間に合っていませんが、今後 ポーティングガイドが追記 されるようです。QDesktopServices::DataLocation を QStandardPaths::DataLocation に変更する場合には注意してください。(QCoreApplication::applicationName のデフォルト値が Qt4 と Qt5 で異なることも影響しているようですが。)

ちなみに、上記の変更点は Forum の以下のスレッドから派生して反映されているものがいくつかあります。こちらに詳しく記述してある件もあるので参考にしてみてください。

関連記事

カテゴリーQtタグ

4 Replies to “Qt 5.1.0 の変更点(補足)”

  1. Qt5からですが、qDebug() の日本語の文字化けが解消できません。
    Qt4で使用できたQTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
    のsetCodecForCStringsという staticメンバ関数が無くなっています。
    替わりに
    QTextCodec::setCodecForLocale(QTextCodec::codecForName(“Shift-JIS”));
    を使用してみましたが NGでした。

    1. QTextCodec::setCodecForCStrings() の削除は Qt 5.0 からですね。
      Qt ではソースファイルが UTF-8 であることを仮定しているので、qDebug() << "テキスト" とした場合、QString::fromUtf8() が使用されています。 Visual Studio がリテラルを S-JIS に変換してしまうことも合わさって、化けてしまうということになります。 QString::fromLocal8Bit() で囲んでしまうのが無難な手ですが、タイプ量的に面倒です。 もう少し調べてみます。

  2. 市田です。 朝木さん。 お返事ありがとうございます。 メール通知がスパムフィルタで消されてしまってコメントに気が付くのが遅れました。 申し訳ございません。

    さて、
    QString::fromLocal8Bit() で囲んでみたのですが文字化けは解消しませんでした。

    さらに、
    Qt は qt-windows-opensource-5.1.0-msvc2010_opengl-x86-offline.exe ですが、
    Visual Studio に限らず、Qt5.1付属の Qt Creator 2.7.2 で作成した Qt コンソールアプリケーションでも同様の文字化けが出ます。 (環境Windows 7 SP1 64bit)

    例えば

    qDebug() << QString::fromLocal8Bit("名前を入力してください");  //文字化け

    std::cout << "名前を入力してください";   //文字化け

    std::cout << QString::fromLocal8Bit("名前を入力してください");   //コンパイルエラー

    でした。

    1. 市田です。 情報を少し訂正いたします。 Qt Creator で新規ファイルを追加するとUTF-8 ですが、何故かBOM無しになっていたのを、別のエディタでBOM付きにすると以下の結果になりました。

      qDebug() << "名前を入力してください"; //文字化け
      qDebug() << QString::fromLocal8Bit("名前を入力してください");  //正常
      std::cout << "名前を入力してください";   //正常
      ということで、QString::fromLocal8Bit() は使えるということでした。

T.Ichida にコメントする コメントをキャンセル

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください