Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. create a child object with initial data
Forum Updated to NodeBB v4.3 + New Features

create a child object with initial data

Scheduled Pinned Locked Moved Unsolved General and Desktop
25 Posts 4 Posters 3.8k Views 1 Watching
  • 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.
  • M megido

    @JonB
    I just don't know another way if it exists

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #21

    @megido
    I can't go through it again. I said that your original way was fine, with no parameters

      Form *AF =  new Form;
      // here a few connects()
      AF->set_user_date(user_date);
      AF->show();
    

    I told you that was fine. You then started saying the date was not initialised in the constructor. I replied:

    I don't see what there is to say. Yes, the date is empty/default during the constructor, it gets changed to the desired date when the setter is called. What else would you expect, and what is the problem? Like I wrote, if you really need it to be set during the constructor you would have to add a parameter for it, but there is no obvious reason why you would need that.

    You didn't say anything about why you have to have it initialized in the constructor. I do not see why you care about the log messages, they are no problem. You just started asking how to pass it as a parameter. So that is what I answered.

    The best way is your original code. Answer why you care about when it is initilalized, what is unacceptable about this code?

    M 1 Reply Last reply
    0
    • M megido

      @JonB
      I just don't know another way if it exists

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #22

      @megido Can you show how you implemented set_user_date()?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @megido Can you show how you implemented set_user_date()?

        M Offline
        M Offline
        megido
        wrote on last edited by
        #23

        @jsulm I have delete that. it was a private void

        jsulmJ 1 Reply Last reply
        0
        • JonBJ JonB

          @megido
          I can't go through it again. I said that your original way was fine, with no parameters

            Form *AF =  new Form;
            // here a few connects()
            AF->set_user_date(user_date);
            AF->show();
          

          I told you that was fine. You then started saying the date was not initialised in the constructor. I replied:

          I don't see what there is to say. Yes, the date is empty/default during the constructor, it gets changed to the desired date when the setter is called. What else would you expect, and what is the problem? Like I wrote, if you really need it to be set during the constructor you would have to add a parameter for it, but there is no obvious reason why you would need that.

          You didn't say anything about why you have to have it initialized in the constructor. I do not see why you care about the log messages, they are no problem. You just started asking how to pass it as a parameter. So that is what I answered.

          The best way is your original code. Answer why you care about when it is initilalized, what is unacceptable about this code?

          M Offline
          M Offline
          megido
          wrote on last edited by megido
          #24

          @JonB yes, I have understood you. I too long time ago developed on Qt and forgot many. In this situation a just should call in the setter.

          ui->dateedit->setDate(date);
          

          but instead that I tried to update the variable before using it in the constructor. Because I thought what I really should predefine values in fields before the draw(It's usual for the WEB development).

          1 Reply Last reply
          0
          • M megido

            @jsulm I have delete that. it was a private void

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #25

            @megido said in create a child object with initial data:

            I have delete that. it was a private void

            Why not making it public and use instead of deleting?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

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