Results 1 to 10 of 10

Thread: Loader work just one time

  1. #1
    Join Date
    Dec 2013
    Location
    Jerada, Morroco
    Posts
    106
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Loader work just one time

    Hi all,

    I'm using Loader in order to load a file.qml from an other file , and it works perfectely but just one time
    there is my code

    Qt Code:
    1. Loader {
    2. id: dialogLoader
    3. onLoaded: {
    4. console.log("FILE LOADED")
    5. }
    6. }
    To copy to clipboard, switch view to plain text mode 

    and in the event onClick

    Qt Code:
    1. Button{
    2. id:btn
    3. text: "tata"
    4. Image {
    5. source: "qrc:/plgmgrresources/qml/applications/images/icon1.png"
    6. anchors.left: parent.left
    7. anchors.leftMargin: 5
    8. anchors.verticalCenter: parent.verticalCenter
    9. width: 16
    10. height: 16
    11. }
    12. width: 150
    13. onClicked: {
    14. dialogLoader.source = "qrc:/plgmgrresources/qml/applications/file2.qml"
    15. }
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 

    Have you any explaination for this issue ?
    ps : sorry for my english

  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: Loader work just one time

    Your code snippet doesn't show where you unload or load something different.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2013
    Location
    Jerada, Morroco
    Posts
    106
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Loader work just one time

    there is no something different, in the same button , the fisrt click load the file qml , but when i close it and try to load it again it dosen't work

  4. #4
    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: Loader work just one time

    When you close what?
    There is nothing in your code that indicates closing.

    All there seems to be is a loader and it gets its source property set to a single specific value.

    Cheers,
    _

  5. #5
    Join Date
    Dec 2013
    Location
    Jerada, Morroco
    Posts
    106
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Loader work just one time

    when i close the file2.qml , it is an application window , so i can close it , but when i click in the button to reload it it doesn't work

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

    Default Re: Loader work just one time

    Why would it work? The loader still refers to the same file. The window is just closed.
    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.


  7. #7
    Join Date
    Mar 2015
    Posts
    2
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows Android

    Default Re: Loader work just one time

    You can you this solution ,it will be useful for you
    Rectangle {
    ....
    Button{
    id:btnAddTile
    text: qsTr("Add new tile")
    width: 90
    height: 25
    anchors.horizontalCenter: parent.horizontalCenter
    onClicked: {

    var component = Qt.createComponent("File2.qml");
    if (component.status === Component.Ready)
    component.createObject(parent, {"x": 100, "y": 100});


    }
    }

    }

    File2.qml :

    ApplicationWindow {

    .....
    }

  8. #8
    Join Date
    Dec 2013
    Location
    Jerada, Morroco
    Posts
    106
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Loader work just one time

    Yes wysota exactly , that was my question
    rayan what is the diffrence between using laoder and using createComponent ?

  9. #9
    Join Date
    Mar 2015
    Posts
    2
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows Android

    Default Re: Loader work just one time

    with createComponent your problem is resolved , so you can click on your button as far as to want

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

    Default Re: Loader work just one time

    Quote Originally Posted by hassinoss View Post
    Yes wysota exactly , that was my question
    What was your question? Your window is there, just make it visible.
    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.


Similar Threads

  1. SQL query does not work every time
    By Mobility in forum Newbie
    Replies: 8
    Last Post: 13th January 2013, 06:48
  2. Replies: 2
    Last Post: 16th October 2011, 07:53
  3. C++/Qt, remote work, part-time
    By mannaz in forum Jobs
    Replies: 3
    Last Post: 15th June 2011, 17:09
  4. setValue of ScrollBar Don't work at first time
    By sergio87 in forum Qt Programming
    Replies: 8
    Last Post: 8th June 2011, 10:00
  5. Replies: 0
    Last Post: 12th August 2010, 16:05

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
  •  
Qt is a trademark of The Qt Company.