Ubuntu 22.04 配置qtchooser默认启用 Qt6

文章目录

  • 问题现象
  • 解决方案
    • 系统解决方案 1. Select Qt6 system-wide
    • 当前用户解决方案 2. Select Qt6 for current user only
  • 参考资料

问题现象

In Ubuntu 22.04 there is currently an open bug QtChooser doesnt support qt6.

So even if Qt6 has been installed using sudo apt install qt6-base-dev, qtchooser -l does not list a qt6 option and qmake outputs qmake: could not find a Qt installation of ‘’.

Assuming Qt6 is installed and qmake6 can be called, I believe there are two options:

解决方案

系统解决方案 1. Select Qt6 system-wide

  • Generate qt6.conf based on the path to qmake6
qtchooser -install qt6 $(which qmake6)
  • Move/copy qt6.conf to system-wide dir
# sudo mv ~/.config/qtchooser/qt6.conf /usr/share/qtchooser/qt6.conf
sudo cp ~/.config/qtchooser/qt6.conf /usr/share/qtchooser/qt6.conf
  • Set Qt6 as default option
sudo mkdir -p /usr/lib/$(uname -p)-linux-gnu/qt-default/qtchooser
sudo ln -sf /usr/share/qtchooser/qt6.conf /usr/lib/$(uname -p)-linux-gnu/qt-default/qtchooser/default.conf

当前用户解决方案 2. Select Qt6 for current user only

  • Generate qt6.conf based on path to qmake6
qtchooser -install qt6 $(which qmake6)
  • Select Qt6 as default (place in ~/.bashrc for persistence):
export QT_SELECT=qt6

参考资料

  • https://askubuntu.com/questions/1460242/ubuntu-22-04-with-qt6-qmake-could-not-find-a-qt-installation-of

你可能感兴趣的:(Ubuntu专栏,ubuntu,linux,qt6,qtchooser)