13

First of all i need to create a "hello world" app using QML & QT Creator as described here http://developer.ubuntu.com/get-started/gomobile/

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: https://askubuntu.com/questions/235440/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
    width: units.gu(60)
    height: units.gu(80)
    color: "lightgray"

    property real margins: units.gu(2)
    property real buttonWidth: units.gu(9)

    Label {
       id: title
       ItemStyle.class: "title"
       text: i18n.tr("Currency Converter")
       height: contentHeight + root.margins
       anchors {
           left: parent.left
           right: parent.right
           top: parent.top
       }
    }
}
9
  • 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 Jan 3, 2013 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, 2013 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, 2013 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? Jan 4, 2013 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 .paste.ubuntu.com/1658717 and I am getting the red line at import Ubuntu.Components 0.1. What I have to do now.
    – Raja G
    Feb 15, 2013 at 16:55

4 Answers 4

3

I found out the solution at least for ubuntu 12.04. I had to go to the official site http://qt-project.org/downloads#qt-creator 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 qt-linux-opensource-5.0.0-x86_64-offline.run

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

  • ./qt-linux-opensource-5.0.0-x86_64-offline.run

  • 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)

1
  • That red line is distracting for a perfectionist like myself. Any way to fix whatever's causing it?
    – Djentleman
    Jan 16, 2013 at 3:49
0

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.

0

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.

0

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 textures.pro 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .