[Gtkmm] Kompilierfehler, aber warum?
-
Hi, ich hab da folgendes Programm Fabriziert, welches einen horizontalen Slider in nem Fenster darstellen soll.
Beim Kompilieren bekomme ich jetzt folgende Fehlermeldung:D:\projects\codeblocks\gtkmm-slider-demo\gtkmm-slider-demo\box.cpp||In constructor `mybox::mybox()':| D:\projects\codeblocks\gtkmm-slider-demo\gtkmm-slider-demo\box.cpp|4|error: no matching function for call to `Gtk::Adjustment::Adjustment()'| C:\GTK\include\gtkmm-2.4\gtkmm\adjustment.h|135|note: candidates are: Gtk::Adjustment::Adjustment(double, double, double, double, double, double)| C:\GTK\include\gtkmm-2.4\gtkmm\adjustment.h|85|note: Gtk::Adjustment::Adjustment(GtkAdjustment*)| C:\GTK\include\gtkmm-2.4\gtkmm\adjustment.h|84|note: Gtk::Adjustment::Adjustment(const Glib::ConstructParams&)| C:\GTK\include\gtkmm-2.4\gtkmm\adjustment.h|80|note: Gtk::Adjustment::Adjustment(const Gtk::Adjustment&)| D:\projects\codeblocks\gtkmm-slider-demo\gtkmm-slider-demo\box.cpp|5|error: no match for call to `(Gtk::Adjustment) (double, double, double, double)'| D:\projects\codeblocks\gtkmm-slider-demo\gtkmm-slider-demo\box.cpp|6|error: no match for call to `(Gtk::HScale) (Gtk::Adjustment&)'| ||=== Build finished: 3 errors, 0 warnings ===|Warum wird der Konstruktor nicht erkannt? Die letzten 3 Doubles sind ja vorbelegt.
Warum erscheint als mutmaßlicher Konstruktor "Gtk::Adjustment::Adjustment()", obwohl ich drei doubles als Parameter mitgegeben habe??Hier der Quellcode:
//box.h #ifndef BOX_H_INCLUDED #define BOX_H_INCLUDED #include <gtkmm.h> class mybox : public Gtk::HBox { protected: Gtk::Adjustment myAdjustment; Gtk::HScale myScale; public: mybox(); virtual ~mybox(); }; #endif // BOX_H_INCLUDED//box.cpp #include "box.h" #include <iostream> mybox::mybox() { myAdjustment(0.0, 0.0, 1.0, 0.1); myScale(myAdjustment); myScale.set_update_policy(Gtk::UPDATE_CONTINUOUS); myScale.set_value_pos(Gtk::POS_TOP); add(myScale); show_all_children(); } mybox::~mybox() { }//main.cpp #include <gtkmm.h> #include "box.h" int main(int argc,char* argv[]) { Gtk::Main kit(argc,argv); Gtk::Window main_window; main_window.set_default_size(640,480); mybox my_box; main_window.add(my_box); main_window.show_all_children(); kit.run(main_window); return 0; }
-
So kannst du Memberkonstruktoren nicht aufrufen. Benutz eine Initialisierungsliste.
-
thx, mit ner initializer list funktioniert's