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. problem setting the visibility of widget.
Qt 6.11 is out! See what's new in the release blog

problem setting the visibility of widget.

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

    i have copule of widget in ui file.
    so i use setVisible to false to hide some of them.

    then i later tried to show them by using setVisible(1) .
    but it dose not shows the widget.

    ui->calandarW->setVisible(0);
    ui->timeW->setVisible(0);
    ui->batteryW->setVisible(0);
    ui->sysW->setVisible(0);
    ui->networkW->setVisible(0);
    ui->timeW->setVisible(0);
    
    if(sm.getShowTime() == 1){//getting bool from qsetting
            ui->timeW->setVisible(1);
        }
    

    note : sure, setting is giving me true.

    i also tried this .

    //hiding all the widgets
    ui->calculatorW->setVisible(1);
    ui->calandarW->setVisible(0);
    ui->timeW->setVisible(0);
    ui->batteryW->setVisible(0);
    ui->sysW->setVisible(0);
    ui->networkW->setVisible(0);
    
    //then only showing the calculatorW
    ui->calculatorW->setVisible(1);
    

    not working. not showing the "calculatorW" widget.

    HERE IS THE CPP FILE GITHUB

    what is the problem?

    JKSHJ 1 Reply Last reply
    0
    • S saber

      i have copule of widget in ui file.
      so i use setVisible to false to hide some of them.

      then i later tried to show them by using setVisible(1) .
      but it dose not shows the widget.

      ui->calandarW->setVisible(0);
      ui->timeW->setVisible(0);
      ui->batteryW->setVisible(0);
      ui->sysW->setVisible(0);
      ui->networkW->setVisible(0);
      ui->timeW->setVisible(0);
      
      if(sm.getShowTime() == 1){//getting bool from qsetting
              ui->timeW->setVisible(1);
          }
      

      note : sure, setting is giving me true.

      i also tried this .

      //hiding all the widgets
      ui->calculatorW->setVisible(1);
      ui->calandarW->setVisible(0);
      ui->timeW->setVisible(0);
      ui->batteryW->setVisible(0);
      ui->sysW->setVisible(0);
      ui->networkW->setVisible(0);
      
      //then only showing the calculatorW
      ui->calculatorW->setVisible(1);
      

      not working. not showing the "calculatorW" widget.

      HERE IS THE CPP FILE GITHUB

      what is the problem?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @saber Is the coreaction widget visible? If it is hidden, then all of its child widgets will be hidden too.

      Note: You can replace setVisible(1) with show(), and setVisible(0) with hide().

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      S 1 Reply Last reply
      1
      • JKSHJ JKSH

        @saber Is the coreaction widget visible? If it is hidden, then all of its child widgets will be hidden too.

        Note: You can replace setVisible(1) with show(), and setVisible(0) with hide().

        S Offline
        S Offline
        saber
        wrote on last edited by
        #3

        @JKSH

        coreaction widget is shown on start up then after 8 second it's hidden.

        mrjjM JKSHJ 2 Replies Last reply
        0
        • S saber

          @JKSH

          coreaction widget is shown on start up then after 8 second it's hidden.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @saber
          Hi
          Just so we are clear. All Widgets within another widget cannot be visible
          unless the parent widget is. So there is no need to hide all children.
          You can just hide/show the parent.
          setVisible is proven to work so its something else in your code.

          Does it work if you dont try to hide anything from start ? All is shown?

          S 1 Reply Last reply
          2
          • mrjjM mrjj

            @saber
            Hi
            Just so we are clear. All Widgets within another widget cannot be visible
            unless the parent widget is. So there is no need to hide all children.
            You can just hide/show the parent.
            setVisible is proven to work so its something else in your code.

            Does it work if you dont try to hide anything from start ? All is shown?

            S Offline
            S Offline
            saber
            wrote on last edited by
            #5

            @mrjj
            if i not hide or setVisible(0) then all the widget shows just fine.

            u could see the cpp file coreaction cpp

            1 Reply Last reply
            0
            • S saber

              @JKSH

              coreaction widget is shown on start up then after 8 second it's hidden.

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              @saber said in problem setting the visibility of widget.:

              coreaction widget is shown on start up then after 8 second it's hidden.

              When the coreaction widget is not visible, ui->calculatorW->setVisible(1); will not make calculatorW visible.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              1
              • S Offline
                S Offline
                saber
                wrote on last edited by
                #7

                i found the problem.
                i put most of the widget in battery widget.
                so if battery widget is shown most of the widget is shown.

                it happened in ui.
                silly mistake .
                sorry everyone.

                1 Reply Last reply
                1

                • Login

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