Qtの設定 - Qt5プロジェクトへの移行

提供:MochiuWiki : SUSE, EC, PCB
2024年10月14日 (月) 11:02時点におけるWiki (トーク | 投稿記録)による版 (文字列「__FORCETOC__」を「{{#seo: |title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki |keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板 |description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This pag…)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

概要

ここでは、Qt5プロジェクトへの移行手順を記載する。


プロジェクトファイル

# Qt4
QT += core gui network webkit

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



QApplicationの宣言

# Qt4
#include <QtGui/QApplication>

# Qt5
#include <QApplication>



ローカルディレクトリ

# Qt4
QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);

# Qt5
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);



QTableWidgetの行の高さを固定する方法が異なる

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

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



ソフトウェアの配布

Qt5プロジェクトにおいて、Windows向けソフトウェアを配布する場合、実行ファイル(.exeファイル)と同じディレクトリに以下のファイルを同梱する。

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



その他の注意点

# Qt4
QHttp

# Qt5
QNetworkAccessManager


# Qt4
QString.toAscii()

# Qt5
QString.toUtf8()


その他、SendMessageが予約語になったため、注意すること。