Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

First of all i need to create a "hello world" app using QML & QT Creator as described here

Second, when i was trying to install QML platform and the dependencies i couldn't run the step 2 (of "Install the Ubuntu QML toolkit preview") because i have a distro (backbox) based on ubuntu 12.04 but i solve it by following the instructions of this post: How do I install the QML toolkit on 12.04?

Third, when i open QTCreator and trying to execute CurrencyConverter (helloWorld app) the program can't find the following packages:

import Ubuntu.Components 0.1

What can i do in order to run the app?

thanks in advance.

import QtQuick 2.0
import Ubuntu.Components 0.1

Rectangle {
    id: root
    color: "lightgray"

    property real margins:
    property real buttonWidth:

    Label {
       id: title
       ItemStyle.class: "title"
       text:"Currency Converter")
       height: contentHeight + root.margins
       anchors {
           left: parent.left
           right: parent.right
share|improve this question
Could you please add more information? How are you actually executing the app? Does the app run if you execute it from the command line? Are you sure you ran the following bit of the installation command on the get started step? echo 'export PATH=/opt/qt5/bin:$PATH' >> ~/.bashrc – David Planella Jan 3 '13 at 20:48
hi, yes of course... I just copy and paste the commands. Is 100% sure that is correct, so the first and the second step are done. After that i opened the QTCreator and i followed the instructions of the third step above. When i paste the above code the line "import Ubuntu.Components 0.1" was highlighted and it was saying "QML Module not found. Import Paths: /usr/lib/qt4/imports". Please note i'm not using ubuntu but a distro based on ubuntu 12.04. The only difference is that have xfce4 and not unity. – CodeArtist Jan 3 '13 at 23:32
@DavidPlanella I'm on 12.10 and experiencing the same. I copied + pasted both commands and everything seemed to have gone fine. In QtCreator with the example - CurrenyConverter.qml:2:1: module "Ubuntu.Components" is not installed (I also got the same error for QtQuick 2.0). echo $PATH /opt/qt5/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/‌​usr/bin:/sbin:/bin:/usr/games:/usr/local/games – trent Jan 4 '13 at 3:28
@JorgeCode, what you are describing is I believe a warning in Qt Creator, which should not stop the code from running. As asked above, do you get an error message when you run your app with qmlscene from the command line, as described in the tutorial? If so, what's the exact output on the command line? – David Planella Jan 4 '13 at 9:15
@DavidPlanella ,I am also getting the same error and this is the code I am getting from the terminal or Qt Creator when I have done compiling and I am getting the red line at import Ubuntu.Components 0.1. What I have to do now. – Raja Feb 15 '13 at 16:55
up vote 3 down vote accepted

I found out the solution at least for ubuntu 12.04. I had to go to the official site and download the latest Qt package which is Qt 5.0.0.

*Note: Ubuntu 12.04 doesn't include the latest Qt version, so you have to download it manually.

*Note: Before the installation i removed the previous version of QtCreator (2.5.0)

All you have to do in order to install Qt5 package is:

  • chmod 755

Then just execute the package and run the installer with the default settings.

  • ./

  • Now should exist /opt/qt5/imports/Ubuntu/Components path, with all the libraries!

After that i followed the instructions of the CurrencyConverter

*Note that line: import Ubuntu.Components 0.1 is still highlighted with a red line but the program runs normally by choosing Tools > External > Qt Quick > Preview (qmlviewer) (thanks to @David Planella)

share|improve this answer
That red line is distracting for a perfectionist like myself. Any way to fix whatever's causing it? – Djentleman Jan 16 '13 at 3:49

You can actually go to options -> build and run -> qt versions (I have Polish version so I had to translate it back to English - sorry if names are slightly different). Then you add latest version of qt, which you already have installed - it's in /opt/qt5/bin.

share|improve this answer

If you have QT5 properly installed and still import Ubuntu.Components 0.1 is highlighted you should do this:

  • open .qmlproject file (included in automatically generated project)
  • add this text: importPaths: [ "/opt/qt5/imports" ] before last closing: }

...and problem should gone.

share|improve this answer

You're probably going to want to run/build all the qt demos by opening the .pro files for the specific examples.

chown -R yourusername /opt/qt5/examples/

When I went to build the opengl/textures example by opening the file within qtcreator, it automatically configured the project BUT it was pointing to QT4 by default. I got a strange error that said it could not find QtWidgets when I was trying to build using qt4. With Qt5 as the build tool, the problem went away.

MAKE SURE YOU POINT TO QT5 as the project build for debug/release because it's not the default in qtcreator. Otherwise you will get strange errors when building. This problem is easy to spot in the compilation output which should be showing qt5 include and qt5 libs paths.

2:58:51: Running steps for project textures...
12:58:51: Starting: "/usr/bin/make" clean -w
make: Entering directory `/opt/qt5/examples/qtbase/opengl/textures-build-Desktop Release'
rm -f qrc_textures.cpp
rm -f moc_glwidget.cpp moc_window.cpp
rm -f glwidget.o main.o window.o qrc_textures.o moc_glwidget.o moc_window.o
rm -f *~ core *.core
make: Leaving directory `/opt/qt5/examples/qtbase/opengl/textures-build-Desktop-Release'
12:58:52: The process "/usr/bin/make" exited normally.
12:58:52: Configuration unchanged, skipping qmake step.
12:58:52: Starting: "/usr/bin/make" -w
make: Entering directory `/opt/qt5/examples/qtbase/opengl/textures-build-Desktop-Release'
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++-64 -I../textures -I../../../../include -I../../../../include/QtOpenGL -I../../../../include/QtWidgets -I../../../../include/QtGui -I../../../../include/QtCore -I. -I. -o glwidget.o ../textures/glwidget.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++-64 -I../textures -I../../../../include -I../../../../include/QtOpenGL -I../../../../include/QtWidgets -I../../../../include/QtGui -I../../../../include/QtCore -I. -I. -o main.o ../textures/main.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++-64 -I../textures -I../../../../include -I../../../../include/QtOpenGL -I../../../../include/QtWidgets -I../../../../include/QtGui -I../../../../include/QtCore -I. -I. -o window.o ../textures/window.cpp
/opt/qt5/bin/rcc -name textures ../textures/textures.qrc -o qrc_textures.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++-64 -I../textures -I../../../../include -I../../../../include/QtOpenGL -I../../../../include/QtWidgets -I../../../../include/QtGui -I../../../../include/QtCore -I. -I. -o qrc_textures.o qrc_textures.cpp
/opt/qt5/bin/moc -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++-64 -I../textures -I../../../../include -I../../../../include/QtOpenGL -I../../../../include/QtWidgets -I../../../../include/QtGui -I../../../../include/QtCore -I. -I. ../textures/glwidget.h -o moc_glwidget.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++-64 -I../textures -I../../../../include -I../../../../include/QtOpenGL -I../../../../include/QtWidgets -I../../../../include/QtGui -I../../../../include/QtCore -I. -I. -o moc_glwidget.o moc_glwidget.cpp
/opt/qt5/bin/moc -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++-64 -I../textures -I../../../../include -I../../../../include/QtOpenGL -I../../../../include/QtWidgets -I../../../../include/QtGui -I../../../../include/QtCore -I. -I. ../textures/window.h -o moc_window.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../mkspecs/linux-g++-64 -I../textures -I../../../../include -I../../../../include/QtOpenGL -I../../../../include/QtWidgets -I../../../../include/QtGui -I../../../../include/QtCore -I. -I. -o moc_window.o moc_window.cpp
g++ -m64 -Wl,-O1 -Wl,-rpath,/opt/qt5/lib -o textures glwidget.o main.o window.o qrc_textures.o moc_glwidget.o moc_window.o   -L/usr/X11R6/lib64 -L/opt/qt5/lib -lQtOpenGL -lQtWidgets -lQtGui -lQtCore -lGL -lpthread 
make: Leaving directory `/opt/qt5/examples/qtbase/opengl/textures-build-Desktop-Release'
12:58:57: The process "/usr/bin/make" exited normally.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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