2016-09-08 5 views
2

세로 상자 레이아웃의 창이 있습니다. 레이아웃 내에서 나는 메뉴 막대, 노트북 및 상태 표시 줄과 같은 3 개의 위젯을 배치했습니다. 메뉴 표시 줄과 상태 표시 줄이 올바르게 작동합니다. 그러나 노트가 예상대로 작동하지 않습니다 : 추가 한 탭 수에 관계없이 탭을 추가하거나 추가하지 않습니다 (즉, _notebook-> get_n_pages()는 항상 1입니다).Gtk :: 노트가 보이지 않음

탭을 추가하는 코드 :

Gtk::Label label; 
Gtk::TreeView widget; 
Gtk::TreeModelColumnRecord colrec; 

// Columns are added here to 'colrec' 

Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(colrec); 

widget.set_model(store); 

_notebook->append_page(widget, label); 

내가 실종 무엇인가? UI는 glade 파일에서로드됩니다. 기본 탭을 제거 했으므로 Glade에서도 잘못 표시됩니다.

답변

1

나는 이것이 범인이라는 것을 100 % 확신하지는 않지만 시작을 위해 Gtk::TreeView은 파괴됩니다. 시도하십시오 gtkmm manage/add vs smart pointers:.

#include <gtkmm.h> 
#include <iostream> 

void add(Gtk::Notebook& _notebook) 
{ 
    Gtk::Label label; 
    auto widget = Gtk::manage(new Gtk::TreeView()); 
    Gtk::TreeModelColumnRecord colrec; 

    // Columns are added here to 'colrec' 

    Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(colrec); 

    widget->set_model(store); 

    _notebook.append_page(*widget, label); 
} 

int main() 
{ 
    auto Application = Gtk::Application::create(); 
    Gtk::Window window; 

    Gtk::Notebook notebook; 
    add(notebook); 
    add(notebook); 

    window.add(notebook); 
    std::cout<<notebook.get_n_pages()<<std::endl; 
    window.show_all(); 
    Application->run(window); 
    return 0; 
} 
+0

다른 접근 방식으로 전환 한 이후 더 이상 문제가 없어서 더 이상 작동하지 않을지 테스트 할 수 없습니다. – azteca1998