set_text () is not displaying the output.



can someone tell me what's wrong with this code I'm trying to make a small program that gets a text typed by the user, and reversed the order of letters and other exhibits in Gtk:: Entry there goes the code:

main.cc

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

struct MyWindow : Gtk::Window
{
    MyWindow();
    void on_btn_Exit();
    void on_btn_Invert();
    void on_btn_Clear();
   
    Gtk::VBox m_vbox;
    Gtk::HBox m_hbox;
    Gtk::Entry m_Entry, m_Exit;
    Gtk::Button btnInvert, btnClear, btnExit;   
};

MyWindow::MyWindow()
: Gtk::Window(),
  m_vbox(true, 10),
  m_hbox(true, 30),
  btnInverter("Invert"),
  btnLimpar("Clear"),
  btnSair("Exit")
{
    set_title("Inverte String - Delta Inffo Informática");
    set_position(Gtk::WIN_POS_CENTER);
    set_border_width(5);
    set_size_request(400, 100);
   
    m_vbox.add(m_Entry);
   
   btnInvert.signal_clicked().connect(sigc::mem_fun(*this,
        &MyWindow::on_btn_Invert));
    m_hbox.add(btnInvert);
   
   btnClear.signal_clicked().connect(sigc::mem_fun(*this,
        &MyWindow::on_btn_Clear));
    m_hbox.add(btnClear);
   
   btnExit.signal_clicked().connect(sigc::mem_fun(*this,
        &MyWindow::on_btn_Exit));
    m_hbox.add(btnExit);
   
    m_vbox.add(m_hbox);   
   
    m_vbox.add(m_Exit);   
   
    add(m_vbox);
   
    show_all_children();
}

void MyWindow::on_btn_Invert()
{
    std::string Entry = m_Entry.get_text();       
    std::string Exit;       
   
    int size = m_Entry.get_text_length();   
   
   
    for(int x = size; x >= 0; x--){
                Exit = Exit + Entry[x];
            }                       
  
       
    m_Exit.set_text(Exit);
   
}

void MyWindow::on_btn_Clear()
{   
    m_Entry.set_text("");
    m_Exit.set_text("");   
}

void MyWindow::on_btn_Exit()
{
    hide();
}

int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);
   
    MyWindow window;
   
    Gtk::Main::run(window);
   
    return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]