How to use Qt with Rust?



Today I’ve decided to learn Rust and I was wondering how hard is to use Qt with Rust. The first Google results gave me, so I’ve decided to give it a shot.

My Qt installation lives in C:\Qt\5.7\ and Qt5Config.cmake lives in C:\Qt\5.7\msvc2015_64\lib\cmake\Qt5

What I’ve tried is:

  • git clone
  • cd qt.inline && mkdir build
  • cmake -D Qt5_DIR=C:\Qt\5.7\msvc2015_64\lib\cmake\Qt5 -G "Sublime Text 2 - Ninja" ..
  • cmake -D Qt5Core_DIR=C:\\Qt\\5.7\\msvc2015_64\\lib\\cmake\\Qt5Core -D Qt5Gui_DIR=C:\\Qt\\5.7\\msvc2015_64\\lib\\cmake\\Qt5Gui -D Qt5Widgets_DIR=C:\\Qt\\5.7\\msvc2015_64\\lib\\cmake\\Qt5Widgets -G "Sublime Text 2 - Ninja" ..
  • cmake -D CMAKE_PREFIX_PATH=C:\\Qt\\5.7\\msvc2015_64\\ -G "Sublime Text 2 - Ninja" ..

but the result was a bunch of errors:

enter image description here

I’ve also tried other Qt folders like {C:\Qt\5.7\msvc2015_64\lib\cmake, C:\Qt\5.7\msvc2015_64\lib, C:\Qt\5.7\msvc2015_64, C:\Qt\5.7\, C:\Qt} with the same luck.

How could I solve this one?

What would Rust’s equivalent to Python’s pyqt/pyside be? Is there any “official” Qt Rust package?


qt.inline depends on Qt. Assuming you installed Qt in your system, the errors suggest you didn’t specify where Qt is installed.

On a “normal” project using find_package(Qt5 ...), you would have done:

cmake .. -D Qt5_DIR=/path/to/qt -G "Sublime Text 2 - Ninja"

Where /path/to/qt is the directory in your Qt install containing Qt5Config.cmake. Given <prefix> is the root dir of your Qt install, this should be something like <prefix>/lib/cmake/Qt5.

qt.inline is more specific and ask explicitly for specific modules of Qt, namely Qt5Core, Qt5Gui and Qt5Widgets. So use the same procedure with these modules:

cmake -D Qt5Core_DIR=/path/to/Qt5CoreConfig.cmake
      -D Qt5Gui_DIR=/path/to/Qt5GuiConfig.cmake
      -D Qt5Widgets_DIR=/path/to/Qt5WidgetsConfig.cmake

Answered By – rgmt

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More