Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Is it ok to add Widgets to Widgets?

    General and Desktop
    3
    3
    55
    Loading More Posts
    • 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.
    • Q
      qwe3 last edited by

      Hi,
      I have class which inherits QComboBox - myComboBox

      Is it ok to create in myComboBox's constructor new widget for example QPushButton like this:

      myComboBox constructor
      {
           button = new QPushButton(this);
           button->setFixedSize(10,10);
           button->move(100,10);
      }
      

      ? Or this may be dangerous?

      KroMignon Pl45m4 2 Replies Last reply Reply Quote 0
      • KroMignon
        KroMignon @qwe3 last edited by

        @qwe3 said in Is it ok to add Widgets to Widgets?:

        Or this may be dangerous?

        There is no danger do this.
        QPushButton will be destroyed, at least, when parent class is destroyed.

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        1 Reply Last reply Reply Quote 3
        • KroMignon
          KroMignon @qwe3 last edited by

          @qwe3 said in Is it ok to add Widgets to Widgets?:

          Or this may be dangerous?

          There is no danger do this.
          QPushButton will be destroyed, at least, when parent class is destroyed.

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          1 Reply Last reply Reply Quote 3
          • Pl45m4
            Pl45m4 @qwe3 last edited by

            Is it ok to add Widgets to Widgets?

            If that would be not ok, you could close this forum and put Qt to the bin ;-)

            @qwe3 said in Is it ok to add Widgets to Widgets?:

            button->setFixedSize(10,10);
            button->move(100,10);

            The only "ugly" thing here is that your button is not part of the internal layout (I think you cant do that anyway), so if you resize or move your checkBox, the button will look always the same


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            1 Reply Last reply Reply Quote 0
            • First post
              Last post