0

gtkmm チュートリアルのhello world の例では、libsigc++ライブラリがhelloword.ccファイル内で使用されています。

#include "helloworld.h"
#include <iostream>

HelloWorld::HelloWorld()
: m_button("Hello World")   // creates a new button with label "Hello World".
{
    // Sets the border width of the window.
    set_border_width(10);

    // When the button receives the "clicked" signal, it will call the
    // on_button_clicked() method defined below.
    m_button.signal_clicked().connect(sigc::mem_fun(*this,
                &HelloWorld::on_button_clicked));

    // This packs the button into the Window (a container).
    add(m_button);

    // The final step is to display this newly created widget...
    m_button.show();
}

ただし、libsigc++このファイルには含まれていませんが、それでも正しく機能します。sigc名前空間はどこから来たのですか?

編集: helloworld.h:

#ifndef GTKMM_EXAMPLE_HELLOWORLD_H
#define GTKMM_EXAMPLE_HELLOWORLD_H

#include <gtkmm/button.h>
#include <gtkmm/window.h>

class HelloWorld : public Gtk::Window
{

  public:
    HelloWorld();
    virtual ~HelloWorld();

  protected:
    //Signal handlers:
    void on_button_clicked();

    //Member widgets:
    Gtk::Button m_button;
};

#endif // GTKMM_EXAMPLE_HELLOWORLD_H
4

2 に答える 2

1

「gtkmm/window.h」の内容をチェックアウト

http://fossies.org/unix/privat/gtkmm-3.6.0.tar.gz/dox/gtk_2gtkmm_2window_8h.html

「sigc++.h」が含まれています

于 2012-11-28T21:13:19.653 に答える
1

インクルードは次の場所にありますmain.h

http://git.gnome.org/browse/gtkmm/tree/gtk/src/main.hg#n22

から含まれていますgtkmm.h

http://git.gnome.org/browse/gtkmm/tree/gtk/gtkmm.h#n181

于 2012-11-29T08:46:40.887 に答える