13

Installed Qt Creator 2.8 in ArchLinux Installed qt5-* (* as every related package) using pacman

examples were not available in the repositories so I used the one in the AUR, qt5-examples

examples are installed under /usr/share/doc/qt/examples

qmake-qt5 -query says:

QT_SYSROOT:
QT_INSTALL_PREFIX:/usr
QT_INSTALL_ARCHDATA:/usr/lib/qt
QT_INSTALL_DATA:/usr/share/qt
QT_INSTALL_DOCS:/usr/share/doc/qt
QT_INSTALL_HEADERS:/usr/include/qt
QT_INSTALL_LIBS:/usr/lib
QT_INSTALL_LIBEXECS:/usr/lib/qt/libexec                                                                                                              
QT_INSTALL_BINS:/usr/lib/qt/bin                                                                                                                      
QT_INSTALL_TESTS:/usr/tests                                                                                                                          
QT_INSTALL_PLUGINS:/usr/lib/qt/plugins                                                                                                               
QT_INSTALL_IMPORTS:/usr/lib/qt/imports                                                                                                               
QT_INSTALL_QML:/usr/lib/qt/qml                                                                                                                       
QT_INSTALL_TRANSLATIONS:/usr/share/qt/translations                                                                                                   
QT_INSTALL_CONFIGURATION:/etc/xdg                                                                                                                    
QT_INSTALL_EXAMPLES:/usr/share/doc/qt/examples                                                                                                       
QT_INSTALL_DEMOS:/usr/share/doc/qt/examples                                                                                                          
QT_HOST_PREFIX:/usr                                                                                                                                  
QT_HOST_DATA:/usr/lib/qt                                                                                                                             
QT_HOST_BINS:/usr/lib/qt/bin                                                                                                                         
QT_HOST_LIBS:/usr/lib                                                                                                                                
QMAKE_SPEC:linux-g++                                                                                                                                 
QMAKE_XSPEC:linux-g++                                                                                                                                
QMAKE_VERSION:3.0
QT_VERSION:5.1.0

which means examples are in the right place

But they are not shown in Qt Creator!

Qt Creator Examples

How can I bring them in qtcreator?

PS: I don't wanna forget about the solution and install SDK.

1

7 Answers 7

11

I know OP asked for archlinux but I faced the same issue with Ubuntu 20.04. To solve it I had to install the following two packages:

sudo apt-get install qtbase5-examples qtbase5-doc-html

This will show the basic widget examples.

Additional examples (e.g. qt quick) can be added by installing them explicitly:

sudo apt install qtquickcontrols2-5-examples

To actually get them displayed in qtcreator I had to install:

sudo apt install qt5-doc qt5-doc-html

Here is the output of echo $(apt-mark showmanual | grep -P '(libqt|qt)')

cmake-qt-gui qt5-default qt5-doc qt5-doc-html qtbase5-dev qtbase5-doc-html qtbase5-examples qtcreator qtquickcontrols2-5-examples

Edit:

Also make sure to install the qml modules you need, for example:

sudo apt install qml-module-qtquick-controls2
5
  • Hi, I just ran into the same issue (on Ubuntu 20.04) and hoped your answer would help, but unfortunately it didn't. Still +1 for the time you took to answer. Here's my output of echo $(apt-mark showmanual|grep -P '^(libqt|qt)'): qt5-default qt5-doc qt5-doc-html qtbase5-examples qtcharts5-examples qtcreator qtcreator-doc. What am I missing? Could you check which other Qt5-related packages you have installed? Oct 7, 2020 at 20:24
  • 1
    Hah, the examples are there (on Ubuntu 20.04). They're located in /usr/lib/x86_64-linux-gnu/qt5/examples for me, which is owned by root:root and not writable to normal users. A simple check with sudo proves they show up as soon as QtCreator finds them writable. Oct 7, 2020 at 20:34
  • I also noticed that one could potentially (but probably shouldn't) manipulate qt.conf to bend the location to one's will. Or simply copy and subsequently chown the examples in some user-writable location. Which is what I am going to do. Please respond to me if a better solution becomes available. Oct 7, 2020 at 21:33
  • Thanks, I have edited my answer with the output of the command you provided. For me the examples are also located in /usr/lib/x86_64-linux-gnu/qt5/examples/ and owned by root:root. When I want to open them, qt creator asks if the example project should be copied to a writable location.
    – evolved
    Oct 8, 2020 at 12:46
  • 1
    I found the actual reason this didn't work for me. Apparently qmake is central to this whole business. In particular qmake -query shows details about the Qt versions it knows about. Now when I freshly installed QtCreator and all that, I still couldn't see the examples. However, inside the Options there is one tab to configure "Qt Versions". In my case nothing was configured after freshly installing the packages. I needed to point it to /usr/bin/qmake which in turn "auto-detected" the Qt I wanted to use. After that, the examples became visible. Oct 8, 2020 at 21:24
2

QtCreator Examples are added in Official Repository 'Extra'

https://www.archlinux.org/packages/extra/any/qt5-examples/

install it using :-

sudo pacman -S qt5-examples
1
  • 1
    I had been incorrectly searching for qtcreator examples. Found what I needed thanks to this.
    – MountainX
    Jan 12, 2020 at 16:41
1

Navigate to the installation location of the examples and open the .pro project file with qt-creator.

Alternatively if you just want to build and run the example. Navigate to the directory qmake and then make and then simple run the output

Additionally if you strictly require the examples to show in the IDE, try launching with admin privileges as the installation directory of the examples may require admin privileges.

4
  • 3
    thanks, but why they are not shown in the examples section in qt creator?
    – Nixmd
    Aug 12, 2013 at 4:11
  • It was empty too, @mdoran3844
    – Nixmd
    Aug 12, 2013 at 4:27
  • i'm all out of ideas. You have any luck?
    – mdoran3844
    Aug 12, 2013 at 7:16
  • Fascinating, you're perfectly right. I tried the packaged version of the examples on Ubuntu (20.04) and they didn't show up. Starting with sudo made them appear ... very very strange. But a closer look revealed why /usr/lib/x86_64-linux-gnu/qt5/examples is owned by root:root and not writable to a normal user. Oct 7, 2020 at 20:32
1

My situation is that qt example folder has no permission to read and execute for non-root users, fixed it and everything OK. In your case:

sudo chmod +rx /usr/share/doc/qt/examples
1
  • Interesting, +1. Checked this and it doesn't apply for Ubuntu (20.04). In Ubuntu I have folders like qtbase5-examples under /usr/share/doc. And yes, I realize the question was for archlinux, but perhaps future readers using Ubuntu will find my comment useful. In Ubuntu examples are in /usr/lib/x86_64-linux-gnu/qt5/examples and are owned by root:root and thus not writable to normal users. Perhaps an issue no one noticed? Oct 7, 2020 at 20:27
1

I am also using archlinux and have had the same problem. Despite not having the examples & demo installed the qmake-qt5 -query is printing a non-existence path.

It seems Qt5 examples are now on AUR(Arch User Repository).

To get the them

  1. Download https://aur.archlinux.org/packages/qt/qt5-examples/qt5-examples.tar.gz
  2. Extract the package maybe with $ tar xzf qt5-examples.tar.gz
  3. cd qt5-examples which contains the PKGBUILD . Then run makepkg .This will download 165MB qt-everywhere-opensource-src-5.2.0.tar.xz
  4. Run pacman -U qt-everywhere-opensource-src-5.2.0.tar.xz
1

Qtcreator cannot detect the example without its html file.

So, in my case I've already installed qtbase5-examples, but could not able to see examples in qtcreator.

After,

sudo apt-get install qtbase5-doc-html

examples are visible in qtcreator. It was the same with qt5serialport-examples.

sudo apt-get install qt5serialport-examples qtserialport5-doc-html

Have a nice one.

-2

make sure you run the qt-opensource-linux-x86-android-5.4.0.run like this:

$sudo ./qt-opensource-linux-x86-android-5.4.0.run

please do not forget the "sudo" or you will find that the examples in the qtcreator is missing.

1
  • 3
    Bad idea to run soemthing as sudo if you do not have to, try if you have Alston's problem, incorrect permissions on the example folder.
    – ted
    Feb 11, 2019 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.