LoginSignup
26
33

More than 5 years have passed since last update.

Qt4 → Qt5 プログラム移行注意点

Last updated at Posted at 2014-03-12

Qt4とQt5のちがいをざっくりまとめてます。以下の点に注意すれば、ビルドは通るはず。

yotsuba_s.jpgxxxx.pro

Qt4:

QT += core gui network webkit

Qt5:

QT += core gui network webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

yotsuba_s.jpgQApplication宣言

Qt4:#include <QtGui/QApplication>
Qt5:#include <QApplication>

yotsuba_s.jpgローカルディレクトリ

Qt4:QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
Qt5:QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);

yotsuba_s.jpgQTableWidgetの行の高さを固定する方法が異なる

Qt4:

ui->tblwgt->verticalHeader()->setResizeMode(QHeaderView::Fixed);

Qt5:

ui->tblwgt->verticalHeader()->setDefaultSectionSize(100);
ui->tblwgt->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);

yotsuba_s.jpgその他注意点

QHttp → QNetworkAccessManager
QString.toAscii() → QString.toUtf8()
SendMessageというワードが予約語(?)になったせいか、ビルドエラーになる場合がある

yotsuba_s.jpgアプリ配布

Qt5でWindowsアプリを配布するときはexeと同じ場所に

platformsフォルダ
 ├ qminimal.dll
 └ qwindows.dll

を同梱すること

以上です。

26
33
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
33