Qt Forum

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

    Solved 如何动态删除 layout

    Chinese
    2
    2
    2837
    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.
    • neeme
      neeme last edited by

      大家好:

      QDialog *dlg;
      dlg = new QDialog;

      QVBoxLayout *la;
      QVBoxLayout *lb;
      QVBoxLayout *lc;

      dlg->setLayout(la);
      la->addLayout(lb)
      la->addLayout(lc);

      lb->addWidget(new Label("***"));
      lb->addWidget(new Label("###"));

      lc->addWidget(new Label("***"));
      lc->addWidget(new Label("###"));

      ............

      怎样把 lb 从界面(dlg) 移除, 而不影向其它布局?谢谢!

      Flotisable 1 Reply Last reply Reply Quote 0
      • Flotisable
        Flotisable @neeme last edited by

        @neeme
        你lb中的widgets是之後都不會再用嗎,還是只是想暫時把它隱藏起來
        如果不會再用,你可以手動去刪除lb中的widgets,然後用removeItem這個function把lb從la移除

        如果還會用到,你只要用hide這個function將lb中的widgets隱藏起來就好了

        不管是哪種情況,我覺得將lb set到一個widget會比較容易,不會再用就只要用removeWidget從la中移除然後刪掉那個widget,還會再用就hide那個widget

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