Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [SOLVED] Loading a MainForm
Forum Update on Monday, May 27th 2025

[SOLVED] Loading a MainForm

Scheduled Pinned Locked Moved Installation and Deployment
4 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Citizen19
    wrote on 4 May 2015, 05:31 last edited by Citizen19 5 Apr 2015, 06:20
    #1

    Hello everybody.

    Newbie user trying QML.

    I am trying to load another form from a returned value from a c++ function basically it goes like this.

    You click a button calls a function then returns a QString.

    Button {
         id: button
         onClicked: {
               mainForm.visible = false
               login.validate(user.text, pass.text).visible = true
          }
    }
    

    The login.validate(user.text, pass.text) returns a QString that will match the id of one of my other ui forms.
    The problem is that it does not load that form and I'm at a loss of why not.
    Any help of what I'm doing wrong is appreciated.
    Thank you.

    P 1 Reply Last reply 4 May 2015, 05:58
    0
    • C Citizen19
      4 May 2015, 05:31

      Hello everybody.

      Newbie user trying QML.

      I am trying to load another form from a returned value from a c++ function basically it goes like this.

      You click a button calls a function then returns a QString.

      Button {
           id: button
           onClicked: {
                 mainForm.visible = false
                 login.validate(user.text, pass.text).visible = true
            }
      }
      

      The login.validate(user.text, pass.text) returns a QString that will match the id of one of my other ui forms.
      The problem is that it does not load that form and I'm at a loss of why not.
      Any help of what I'm doing wrong is appreciated.
      Thank you.

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 4 May 2015, 05:58 last edited by
      #2

      Hi @Citizen19 and Welcome,
      id is a special attribute and it doesn’t work like other properties which means you cannot access it at runtime. You can check it as follows:

      console.log(login.validate(user.text, pass.text).visible)
      //should print 'undefined'
      

      Check more info here.
      You can use something like this

      var formname = login.validate(user.text, pass.text);
      if(formname==="one") 
         form1.visible = true //form1 = id of form
      

      157

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Citizen19
        wrote on 4 May 2015, 06:12 last edited by
        #3

        Thank you p3c0 that worked.

        P 1 Reply Last reply 4 May 2015, 06:17
        0
        • C Citizen19
          4 May 2015, 06:12

          Thank you p3c0 that worked.

          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 4 May 2015, 06:17 last edited by
          #4

          @Citizen19 Glad that helped you :) You can mark the post as solved by editing the post title and prepend [Solved].
          Also to post code blocks please add it inside and ``` (3 backticks) and end with the same. It will display it nicely and will be more readable.

          157

          1 Reply Last reply
          0

          1/4

          4 May 2015, 05:31

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved