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. Is it ok to add Widgets to Widgets?

Is it ok to add Widgets to Widgets?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 164 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.
  • Q Offline
    Q Offline
    qwe3
    wrote on last edited by
    #1

    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?

    KroMignonK Pl45m4P 2 Replies Last reply
    0
    • Q qwe3

      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?

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #2

      @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
      3
      • Q qwe3

        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?

        Pl45m4P Online
        Pl45m4P Online
        Pl45m4
        wrote on last edited by
        #3

        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
        0

        • Login

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