This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Hide NavigationFloatItem

Tags: None
(comma "," separated)
rainbowgoblin
Registered Member
Posts
21
Karma
0

Hide NavigationFloatItem

Mon Oct 20, 2014 6:48 am
I'm having two issues. I have an application that uses MarbleWidget, and I'd like to NOT show the scale bar, compass, and overview map. I call the appropriate functions to do this, i.e., for a MarbleWidget instance called _mapWidget:

Code: Select all
 
  _mapWidget->setShowOverviewMap(false);
  _mapWidget->setShowScaleBar(false);
  _mapWidget->setShowCompass(false);


This works when I do it after changing the theme, but if I do it immediately after creating my MarbleWidget instance, the settings don't seem to stick. So the first question: does my MarbleWidget instance need to be visible first? Are there other things (besides a theme change) that might trigger a reversion of these settings to the defaults?

The second issue: I'd also like to hide the float item that I believe is a NavigationFloatItem (over to the right of the map). This wasn't visible by default in older versions of Marble, and I can't find a setShowNavigation function in the source code. It's possible that I've missed something in the documentation, but I can't seem to figure out what the function to hide this item is called. In the Marble desktop application there's a menu item (View -> Info Boxes -> Navigation) that lets me toggle whether this is visible. Is there some trick to do this in my application, or did I just miss something obvious?

Thanks.
rainbowgoblin
Registered Member
Posts
21
Karma
0

Re: Hide NavigationFloatItem  Topic is solved

Tue Oct 21, 2014 10:53 pm
I've solved both my problems. First, the second problem. I'm fairly certain there's no equivalent to a MarbleWidget::setShowNavigation function. However, the setShow* functions are just convenience functions, there's an easier way to do it: you can just loop over all float items, and set their visibility to false. Or set visibility of select items, as I've done:

Code: Select all
  foreach (AbstractFloatItem * floatItem, _mapWidget->floatItems())
  {
    if (floatItem && (floatItem->nameId() == "overviewmap" ||
                      floatItem->nameId() == "scalebar" ||
                      floatItem->nameId() == "compass" ||
                      floatItem->nameId() == "navigation"))
      floatItem->setVisible(false);
  }


As an added bonus, this works even when I do it RIGHT AFTER creating my MarbleWidget instance, whereas my calls to setShowOverViewMap, etc., did not (which was my first problem).


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], Sogou [Bot]