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. Qt panel in ROS has wrong behavior with collapsible sections with newer version
Forum Updated to NodeBB v4.3 + New Features

Qt panel in ROS has wrong behavior with collapsible sections with newer version

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

    I am working with ROS1 and I developed a custom plugin for a visualizer (RViz) based on Qt. When working with ROS distribution melodic everything worked fine but when I migrated to noetic, it is not working as expected (erratic).

    The Qt panel has been developed using Qt Creator and consists of 3 tabs, 2 of them are collapsible sections within a vertical layout.

    Melodic Noetic
    rviz version 1.13.30 1.14.25
    Qt version 5.9.5 5.12.8

    The layouts and widgets are defined in a QT .ui file. Basically, the collapsible logic is that the tab widget has a vertical layout with QPushButton and QListWidget such as:

    ui_file_qt_creator.png

    And then in the cpp plugin code I connect the push button toggle to the list widget being visible:

    connect(toggle_button, &QPushButton::toggled, this, [=](bool checked) {
            list_widget->setVisible(checked);
          });
    

    When the panel is added as a QDockWidget in the rviz layout, clicking on one of the expandible sections results in a messed visualization. You can see how the front stereo sensors is expanded up to the mbase manager incorrectly.

    bad_expansion_sensors_tab.png

    However, when the plugin is "floating", outside of the rviz panel, the issue disappears and is properly visualized. This is also how it would appear in melodic but as part of a QDockWidget inserted in rviz panel.

    good_expansion_sensors_tab.png

    I have thought about resizing policies and have tried many approaches. Setting fixed sizes with minimum and maximum values, but nothing worked. Also sometimes it glitches and I can solve it by resizing rviz window:

    glitch_expansion_sensors_tab.png

    Any help is welcomed! Thanks for your time :)

    JonBJ 1 Reply Last reply
    0
    • X xavi.rv

      I am working with ROS1 and I developed a custom plugin for a visualizer (RViz) based on Qt. When working with ROS distribution melodic everything worked fine but when I migrated to noetic, it is not working as expected (erratic).

      The Qt panel has been developed using Qt Creator and consists of 3 tabs, 2 of them are collapsible sections within a vertical layout.

      Melodic Noetic
      rviz version 1.13.30 1.14.25
      Qt version 5.9.5 5.12.8

      The layouts and widgets are defined in a QT .ui file. Basically, the collapsible logic is that the tab widget has a vertical layout with QPushButton and QListWidget such as:

      ui_file_qt_creator.png

      And then in the cpp plugin code I connect the push button toggle to the list widget being visible:

      connect(toggle_button, &QPushButton::toggled, this, [=](bool checked) {
              list_widget->setVisible(checked);
            });
      

      When the panel is added as a QDockWidget in the rviz layout, clicking on one of the expandible sections results in a messed visualization. You can see how the front stereo sensors is expanded up to the mbase manager incorrectly.

      bad_expansion_sensors_tab.png

      However, when the plugin is "floating", outside of the rviz panel, the issue disappears and is properly visualized. This is also how it would appear in melodic but as part of a QDockWidget inserted in rviz panel.

      good_expansion_sensors_tab.png

      I have thought about resizing policies and have tried many approaches. Setting fixed sizes with minimum and maximum values, but nothing worked. Also sometimes it glitches and I can solve it by resizing rviz window:

      glitch_expansion_sensors_tab.png

      Any help is welcomed! Thanks for your time :)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @xavi.rv
      I have no idea whether this is relevant to your issue, but your Designer screenshot shows you have not assigned a layout correctly to your Sensors widget. That is what the red "no entry" sign there tells you.

      I think/suspect you have added the QVBoxLayout onto the widget by dragging from the toolbox? What you are supposed to do is:

      1. Add a QWidget.
      2. Add a QPushButton or other widget onto it as a child. (You have to do this step before the next step because the designer is not friendly, IMHO.)
      3. Use right-click menu on widget from first step to assign a layout to the widget.

      You can check, but this should generate different code from what you have done with the layout.

      Does altering that make any difference to your subsequent bad behaviour?

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xavi.rv
        wrote on last edited by
        #3

        Thanks @JonB for the quick response! Just to clarify, the QWidget to add in step1 is the Sensor tab itself or a new widget that is a child to the tab?

        Thanks! I will make the modifications and test to see if it works.

        JonBJ 1 Reply Last reply
        0
        • X xavi.rv

          Thanks @JonB for the quick response! Just to clarify, the QWidget to add in step1 is the Sensor tab itself or a new widget that is a child to the tab?

          Thanks! I will make the modifications and test to see if it works.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @xavi.rv
          In all 3 steps the widget/QWidget is your Sensors. No "extra" widget to be created/added. The difference is that verticalLayout_2 is not added by you dragging a layout from toolbox onto Sensors, rather it is via a right click and option something like Set Layout from context menu on Sensors. But that option will be disabled until Sensors has at least one child widget on it, because that is annoyingly what is required in Designer. If you get it right the Object Explorer you show should not have the "red no entry" sign on it.

          This change may have no relevance to your problem, I do not know, but nonetheless it is the way Designer expects you to set this up.

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xavi.rv
            wrote on last edited by
            #5

            Thanks @JonB. I am not able to remove the red no entry sign from the QWidget in the Sensors tab. I created a new tab just to experiment:

            image.png

            And as you can see the tab has only option to Lay out Horizontally (top bar) and not vertically. I created a QWidget child and added a QPushButton and I am able to properly define that QWidget with a Vertical layout, but not the parent widget (tab).

            Sorry I am quite new to Qt.

            JonBJ 1 Reply Last reply
            0
            • X xavi.rv

              Thanks @JonB. I am not able to remove the red no entry sign from the QWidget in the Sensors tab. I created a new tab just to experiment:

              image.png

              And as you can see the tab has only option to Lay out Horizontally (top bar) and not vertically. I created a QWidget child and added a QPushButton and I am able to properly define that QWidget with a Vertical layout, but not the parent widget (tab).

              Sorry I am quite new to Qt.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @xavi.rv
              What you show on widget is correct. I had not appreciated that tab, and original Sensors, are tabs in a QTabWidget. IIRC that does indeed work differently, and it may be that is the one place you are supposed to get left with "red no entry" sign, I can't remember. And I have no idea how this all relates to your issue which is to do with a QDockWidget which I have never used. So ignore my points here, sorry for any wasted time.

              1 Reply Last reply
              0
              • X Offline
                X Offline
                xavi.rv
                wrote on last edited by xavi.rv
                #7

                It is true that I drag a vertical layout onto the tab. Maybe I can try to add a Widget into the tab rather than the layout and configure the Widget as a Vertical layout as you suggested but within the tab, not the tab itself.
                No worries! I appreciate the effort and thanks for your time :)

                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