Results 1 to 4 of 4

Thread: component from file

  1. #1
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default component from file

    Hello friends,

    when I declare a rectangle in a file:

    TestRect.qml
    Qt Code:
    1. import QtQuick 2.2
    2.  
    3. Rectangle {
    4. color : "green"
    5. anchors.fill: parent
    6. width: 30
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    and try to use it in main.qml



    Qt Code:
    1. ApplicationWindow {
    2. id: root
    3. TestRect{
    4. id:myrect
    5. }
    6. }
    To copy to clipboard, switch view to plain text mode 

    Compiler says :

    TestRect is not a type
    So what is the point here?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: component from file

    Since QML is not compiled, what do you mean with "Compiler says"?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: component from file

    Where is TestRect.qml relative to main.qml?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Re: component from file

    Sorry I mean when I run the program is says
    TestRect is not a type
    It compiles fine. both main.qml and TestRect.qml are in the same folder:

    Projectfolder\
    ------------project.qrc
    ------------main.cpp
    ------------*.cpp
    ------------*.h
    ------------images\
    ------------qml \
    -----------------main.qml
    -----------------TestRect.qml

    Thanks in advance

Similar Threads

  1. using component's id in another QML
    By amitpatel22 in forum Qt Quick
    Replies: 2
    Last Post: 22nd May 2013, 17:01
  2. Add new QML component when binding with C++
    By alenn.masic in forum Qt Programming
    Replies: 2
    Last Post: 5th January 2013, 16:59
  3. TCP/IP Network Component?
    By qtYoda in forum General Programming
    Replies: 2
    Last Post: 16th November 2011, 06:36
  4. Component names.
    By Adante in forum Newbie
    Replies: 1
    Last Post: 29th November 2010, 16:28
  5. Is there an Led component for qt ?
    By lovelypp in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2008, 18:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.