ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The example gvdhoorn points to guided me; the state must be saved as hexadecimal and then everything works as expected once you do the right conversions, the solution is:

Save:

void DisplayTopics::save(rviz::Config config) const
                         {
  rviz::Panel::save(config);

  QByteArray table_header_state(table_->horizontalHeader()->saveState());
  // Must be saved as hex
  config.mapSetValue("table_header_state", table_header_state.toHex());
}

Load:

void DisplayTopics::load(const rviz::Config& config)
{
  rviz::Panel::load(config);

  QString table_header_state_str;
  if (config.mapGetString("table_header_state", &table_header_state_str))
  {
    table_->horizontalHeader()->restoreState(QByteArray::fromHex(qPrintable(table_header_state_str)));
  }
}

The example gvdhoorn @gvdhoorn points to guided me; the state must be saved as hexadecimal and then everything works as expected once you do the right conversions, the solution is:

Save:

void DisplayTopics::save(rviz::Config config) const
                         {
  rviz::Panel::save(config);

  QByteArray table_header_state(table_->horizontalHeader()->saveState());
  // Must be saved as hex
  config.mapSetValue("table_header_state", table_header_state.toHex());
}

Load:

void DisplayTopics::load(const rviz::Config& config)
{
  rviz::Panel::load(config);

  QString table_header_state_str;
  if (config.mapGetString("table_header_state", &table_header_state_str))
  {
    table_->horizontalHeader()->restoreState(QByteArray::fromHex(qPrintable(table_header_state_str)));
  }
}

The example @gvdhoorn points to guided helped me; the state must be saved as hexadecimal and then everything works as expected once you do the right conversions, the solution is:

Save:

void DisplayTopics::save(rviz::Config config) const
                         {
  rviz::Panel::save(config);

  QByteArray table_header_state(table_->horizontalHeader()->saveState());
  // Must be saved as hex
  config.mapSetValue("table_header_state", table_header_state.toHex());
}

Load:

void DisplayTopics::load(const rviz::Config& config)
{
  rviz::Panel::load(config);

  QString table_header_state_str;
  if (config.mapGetString("table_header_state", &table_header_state_str))
  {
    table_->horizontalHeader()->restoreState(QByteArray::fromHex(qPrintable(table_header_state_str)));
  }
}