문제

According to Gtkmm docs Gtk::Scale::Scale is overloaded constructor and can take nothing or Gtk::Orientation.

I created object:

Gtk::Scale m_scale;

And added it to Gtk::HBox

hbox.pack_start(m_scale, false, 0);

But it produces error:

 error: call of overloaded ‘Scale()’ is ambiguous

And it tells me that candidates are Gtk::Scale without any parameter and one with Gtk::Orientation.

How should I force to use Gtk::Scale constructor without parameters?

Thanks, S.

도움이 되었습니까?

해결책

It seems like the constructor taking Gtk::Orientation has a default value for that parameter, therefore it can also be called with no arguments:

public:
  Scale();
  explicit Scale(Orientation orientation = ORIENTATION_HORIZONTAL);

The keyword explicit here does not help, it only possibly disallows converting anything passed in to the Orientation type for it to match.

I say just provide the orientation value, it will at least be explicitly apparent which kind of Scale widget you are creating for anyone else reading the code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top