Trouver une ressource (Nouvelle version du moteur, plus rapide & pertinent, essayez le !)
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
Sujet : wxListCtrl->Problème de mise à jour pendant l'exécution->Fermeture du programme [ Linux / GUI ] (isohelix)
|
wxListCtrl->Problème de mise à jour pendant l'exécution->Fermeture du programme
le 03/05/2008 11:26:49

isohelix
|
Bonjour à tous. Je sais ce que vous allez me dire: "la question à déjà été posée". Et j'ai regardé ce qui se rapprochait de près ou de loin à mon problème mais sans succès: je retape ce que font les autres mais ça ne fonctionne toujours pas. Donc j'expose mon problème. J'ai fait un wxListCtrl qui doit me permettre d'afficher les éléments contenus dans un fichier. Lorsque je le créé au lancement du programme pas de souci. Par contre si je lui demande de tout supprimé en faisanr "myListCtrl->ClearAll();" j'ai droit à un joli "Process aborted. Segmentation fault.". Si quelqu'un pouvait m'aider merci. Voici le code cpp: #include <wx/wx.h> #include "opento.h" #include "wx/aboutdlg.h" #include "parser.h"
BEGIN_EVENT_TABLE( opentoFrame, wxFrame ) EVT_MENU( Menu_File_Quitter, opentoFrame::OnQuit ) EVT_MENU( Menu_Aide_Apropos, opentoFrame::OnAbout ) EVT_MENU( Menu_Aide_Fullscreen, opentoFrame::OnFullscreen ) EVT_MENU( Menu_Import_GDM, opentoFrame::OnImportGDM) END_EVENT_TABLE()
IMPLEMENT_APP(opentoapp)
wxString wsAppName = wxT("eden++");//albatros wxString wsAppVers = wxT("in dev."); wxString iFileName;
wxArrayString iFileContent;
bool opentoapp::OnInit() { opentoFrame *frame = new opentoFrame( wsAppName, wxPoint(50,50), wxSize(450,340) );
frame->Show(TRUE); SetTopWindow(frame); return TRUE; }
opentoFrame::opentoFrame( const wxString& title, const wxPoint& pos, const wxSize& size ) : wxFrame((wxFrame *)NULL, -1, title, pos, size) { //Création des éléments du menu wxMenu *menuFile = new wxMenu;
menuFile->Append( Menu_File_Nouveau, wxT( "&Nouveau \tCtrl+N" ) ); menuFile->Append( Menu_File_Ouvrir, wxT( "&Ouvrir... \tCtrl+O" ) ); menuFile->AppendSeparator(); menuFile->Append( Menu_File_Enregistrer, wxT( "&Enregitrer... \tCtrl+E" ) ); menuFile->Append( Menu_File_EnregistrerSous, wxT( "E&nregitrer sous..." ) ); menuFile->AppendSeparator(); menuFile->Append( Menu_File_Fermer, wxT( "&Fermer \tCtrl+F" ) ); menuFile->AppendSeparator(); menuFile->Append( Menu_File_Quitter, wxT( "&Quitter \tCtrl+Q" ) );
wxMenu *menuImport = new wxMenu;
menuImport->Append( Menu_Import_Leica, wxT( "Carnet Leica/Wild" ) ); menuImport->Append( Menu_Import_Nikon, wxT( "Carnet Nikon" ) ); menuImport->Append( Menu_Import_Sokkia, wxT( "Carnet Sokkia" ) ); menuImport->Append( Menu_Import_Topcon, wxT( "Carnet Topcon" ) ); menuImport->Append( Menu_Import_GDM, wxT( "Carnet Trimble GDM" ) );
wxMenu *menuAide = new wxMenu;
menuAide->Append( Menu_Aide_Fullscreen, wxT( "Plein écran \tF11" ) ); menuAide->AppendSeparator(); menuAide->Append( Menu_Aide_Apropos, wxT( "A &propos..." ) );
wxMenu *menuCalcul = new wxMenu;
menuCalcul->Append( Menu_Calcul_Polygonale, wxT( "Calcul d'une polygonale \tF1" ) ); menuCalcul->AppendSeparator(); menuCalcul->Append( Menu_Calcul_Intersection, wxT( "Intersection \tF2" ) ); menuCalcul->Append( Menu_Calcul_Relevement, wxT( "Relèvement \tF3" ) ); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( menuFile, wxT( "&Fichier" ) ); menuBar->Append( menuImport, wxT( "&Import carnet" ) ); menuBar->Append( menuCalcul, wxT( "&Calcul" ) ); menuBar->Append( menuAide, wxT( "&Aide" ) ); SetMenuBar( menuBar ); CreateStatusBar(); SetStatusText( wxT( "Bienvenue dans " ) + wsAppName + wxT("!"));
this->bFullscreen = false; this->iFirstSizing = 0;
wxBoxSizer *mySizer = new wxBoxSizer( wxVERTICAL );
wxListCtrl *myListCtrl = new wxListCtrl(this, ID_WXLISTCTRL1, wxPoint(0,0), wxSize(this->GetSize().x+360, this->GetSize().y), wxLC_REPORT|wxSUNKEN_BORDER, wxDefaultValidator, wxT("wxListCtrlNameStr") );
myListCtrl->InsertColumn( 0, _("Ligne"), wxLIST_FORMAT_RIGHT, -1); myListCtrl->InsertColumn( 1, _("Eléments"), wxLIST_FORMAT_LEFT, 100); myListCtrl->InsertColumn( 2, _("Matricule"), wxLIST_FORMAT_LEFT, -1); myListCtrl->InsertColumn( 3, _("Paramètres"), wxLIST_FORMAT_LEFT, 500); myListCtrl->InsertColumn( 4, _("Symbole"), wxLIST_FORMAT_LEFT, -1); myListCtrl->InsertItem(1,wxT("000001"),0); myListCtrl->SetItem(0,1,wxT("COMMENTAIRE"));
mySizer->Add(myListCtrl, wxALL|wxEXPAND); mySizer->SetSizeHints(this); SetSizer(mySizer);
//SetSizeHints(wxWindow* window
}
void opentoFrame::OnQuit( wxCommandEvent& WXUNUSED( event ) ) { Close(TRUE); }
void opentoFrame::OnAbout( wxCommandEvent& WXUNUSED( event ) ) { /*wxMessageBox( wxT( "This is a wxWidgets Hello world sample" ), wxT( "About Hello World" ), wxOK | wxICON_INFORMATION, this );*/
wxAboutDialogInfo info; info.SetName( wsAppName ); info.SetVersion( wsAppVers ); info.SetDescription(wsAppName + wxT(" est un logiciel de calcul topographique open source.\n\n")); info.AddDeveloper( wxT("Arno Rubicceni <arno.rubicceni@fakemail.it>") ); info.SetCopyright( wxT("Copyrights: Arno Rubicceni, Almost Perfect Developments and\nThe OpenValley Computing Company, April 2008.\nAll rights reserved.\n\nAll sources can be found at") ); info.SetWebSite(wxT("http://askorn.free.fr/opento")); wxAboutBox( info ); }
void opentoFrame::OnFullscreen( wxCommandEvent& WXUNUSED( event ) ) { this->bFullscreen = !this->bFullscreen; this->ShowFullScreen(this->bFullscreen, 0); }
void opentoFrame::OnImportGDM( wxCommandEvent& WXUNUSED( event ) ) { iFileName = wxFileSelector( wxT("Choisissez un carnet de terrain Trimble Geodimeter"), wxT(""), wxT(""), wxT(""), wxT("Fichier Trimble GDM Job (*.raw)|*.raw"), wxOPEN|wxFILE_MUST_EXIST, NULL, -1, -1);
if( iFileName != wxT("") ) { //iFileContent = ParseGDMFile( iFileName ); ParseGDMFile( iFileName ); }
}
void opentoFrame::ParseGDMFile( wxString wsIn ) {
DelimitedFileParser fileParser( wsIn.mb_str(wxConvUTF8), "=" );
/*On analyse le fichier*/ fileParser.Parse();
/*Nombre de lignes*/ uint uiLignes = fileParser.NumRows();
/*On obtient le nombre de colonnes*/ DelimitedRow row = fileParser.getRow(0); uint uiColonnes = row.NumColumns();
if( uiColonnes == 2 ) { myListCtrl->ClearAll(); }
}
et voici le header: #ifndef _OPENTO_H_ #define _OPENTO_H_
/** * @short Application Main Window * @author the opento committee <one@zenwalk> * @version 0.1 */
class opentoapp : public wxApp { public: virtual bool OnInit(); };
class opentoFrame : public wxFrame { public: opentoFrame( const wxString& title, const wxPoint& pos, const wxSize& size ); void OnQuit( wxCommandEvent& event ); void OnAbout( wxCommandEvent& event ); void OnFullscreen( wxCommandEvent& event ); void OnImportGDM( wxCommandEvent& event ); void ParseGDMFile( wxString wsIn );
bool bFullscreen; uint iFirstSizing; wxBoxSizer *mySizer; wxListCtrl *myListCtrl;
private: DECLARE_EVENT_TABLE(); wxMenuBar *menuBar; wxMenu *menuAide; };
enum { Menu_Import_Topcon = 1017, Menu_Import_Nikon = 1016, Menu_Import_Sokkia = 1015, Menu_File_Nouveau = 1014, Menu_Calcul_Polygonale = 1013, Menu_Calcul_Intersection = 1012, Menu_Calcul_Relevement = 1011, ID_WXLISTCTRL1 = 1010, //ID_WXSTATICBOX1 = 1009, Menu_Aide_Fullscreen = 1008, Menu_Aide_Apropos = 1007, Menu_Import_Leica = 1006, Menu_Import_GDM = 1005, Menu_File_Quitter = 1004, Menu_File_Fermer = 1003, Menu_File_EnregistrerSous = 1002, Menu_File_Enregistrer = 1001, Menu_File_Ouvrir = 1000 };
#endif // _OPENTO_H_
Je programme sous linux avec KDevelop et wxGTK.
|
|
|
|
Re : wxListCtrl->Problème de mise à jour pendant l'exécution->Fermeture du programme
le 03/05/2008 12:24:07

luhtor
|
Avec ce genre d'abérration, c'est normal que ca va pas marcher:
wxBoxSizer *mySizer = new wxBoxSizer( wxVERTICAL );
wxListCtrl *myListCtrl = new wxListCtrl(this, ID_WXLISTCTRL1, wxPoint(0,0),
Avec 90% de la réponse à ton pb, tu ne devrais plus avoir de pb pour comprendre pourquoi ca ne marche pas. Encore une fois, un débuggeur t'aurais permis de comprendre le pb "seul".
Conclusion, attention aux étourderies ... et un débuggeur, c'est fait pour etre utiliser. Et derniere conclusion, TOUJOURS initialiser les pointeurs à NULL. A défaut d'utiliser le debuggeur, tu aurais eu un message un peu plus parlant.
opentoFrame::opentoFrame( const wxString& title, const wxPoint& pos, const wxSize& size ) : wxFrame((wxFrame *)NULL, -1, title, pos, size), bFullscreen(false), iFirstSizing(0), mySizer(NULL), myListCtrl(NULL), menuBar(NULL), menuAide(NULL) {
|
|
|
Classé sous : menu, file, append, wxt, opentoframe
|
Téléchargements
Logiciels à télécharger sur le même thème :
|