In Qt Creator, examples are missed

24,598

Solution 1

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

Solution 2

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.

Solution 3

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

Solution 4

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.

Solution 5

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
Share:
24,598

Related videos on Youtube

Nixmd
Author by

Nixmd

Updated on July 09, 2022

Comments

  • Nixmd
    Nixmd almost 2 years

    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.

  • Nixmd
    Nixmd almost 11 years
    thanks, but why they are not shown in the examples section in qt creator?
  • Nixmd
    Nixmd almost 11 years
    It was empty too, @mdoran3844
  • mdoran3844
    mdoran3844 almost 11 years
    i'm all out of ideas. You have any luck?
  • ted
    ted over 5 years
    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.
  • 0xC0000022L
    0xC0000022L over 3 years
    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?
  • 0xC0000022L
    0xC0000022L over 3 years
    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?
  • 0xC0000022L
    0xC0000022L over 3 years
    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.
  • 0xC0000022L
    0xC0000022L over 3 years
    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.
  • 0xC0000022L
    0xC0000022L over 3 years
    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.
  • 0xC0000022L
    0xC0000022L over 3 years
    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.