Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 如何动态删除 layout
Forum Updated to NodeBB v4.3 + New Features

如何动态删除 layout

Scheduled Pinned Locked Moved Solved Chinese
2 Posts 2 Posters 3.4k Views 2 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.
  • neemeN Offline
    neemeN Offline
    neeme
    wrote on last edited by
    #1

    大家好:

    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) 移除, 而不影向其它布局?谢谢!

    FlotisableF 1 Reply Last reply
    0
    • neemeN neeme

      大家好:

      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) 移除, 而不影向其它布局?谢谢!

      FlotisableF Offline
      FlotisableF Offline
      Flotisable
      wrote on last edited by
      #2

      @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
      0

      • Login

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