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. Hiding the control in a layout and filling it with the other control
Forum Updated to NodeBB v4.3 + New Features

Hiding the control in a layout and filling it with the other control

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 244 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.
  • T Offline
    T Offline
    thomasjohnaj
    wrote on last edited by
    #1

    I have to custom widgets which are displayed side by side in a QHBoxLayout as shown in the picture.

    0b36ea40-113c-4a78-aaf6-af572952b8b2-image.png

    In the Widget2 there is a signal attached to a slot which constantly monitors for a variable. if the variable is null then widget2 should not be displayed and widget1 should stretch to the entire area of the layout. as shown in the picture below.

    725c6b27-669c-4215-8ff4-ff675abb9962-image.png

    What I have written for the state when the two widgets are displayed

    widget1 = new Widget1(this);
    widget2 = new Widget2(this);
    QHboxLayout* hLayout = new QHboxLayout();
    hLayout->addwidget( widget1,5);
    hLayout->addwidget(widget2,95);

    How I can hide this and achieve the state 2 based on the subscribed variable change output?

    Pl45m4P 1 Reply Last reply
    0
    • T thomasjohnaj

      I have to custom widgets which are displayed side by side in a QHBoxLayout as shown in the picture.

      0b36ea40-113c-4a78-aaf6-af572952b8b2-image.png

      In the Widget2 there is a signal attached to a slot which constantly monitors for a variable. if the variable is null then widget2 should not be displayed and widget1 should stretch to the entire area of the layout. as shown in the picture below.

      725c6b27-669c-4215-8ff4-ff675abb9962-image.png

      What I have written for the state when the two widgets are displayed

      widget1 = new Widget1(this);
      widget2 = new Widget2(this);
      QHboxLayout* hLayout = new QHboxLayout();
      hLayout->addwidget( widget1,5);
      hLayout->addwidget(widget2,95);

      How I can hide this and achieve the state 2 based on the subscribed variable change output?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @thomasjohnaj

      widget2->setVisible(false);
      or
      widget2->hide();

      Edit:
      You mixed the names in your image and in your description text. "Widget1 should stretch", but image label says "widget2" :)
      But doesnt matter... it's the same for every widget :)


      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
      3

      • Login

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