Hallo, wiedermal QT ... hab hier folgendes Problem:
die Datei optionwidget.h:
#ifndef OPTIONWINDOW_H #define OPTIONWINDOW_H #include <qwidget.h> #include <qlineedit.h> #include <qstring.h> #include <qlabel.h> #include <qsettings.h> class OptionDialog: public QWidget { Q_OBJECT
public: OptionDialog(QWidget *parent =0, const char *name = 0, WFlags f = 0); void ladeconf();
private: QLineEdit *lmailserv, *lpopserv, *luser, *lpassword, *lpath, *lmaildat, *lamaildat; signals: void geaendert(const QString &);
private slots: void sichereconf(); void schaltesicht(); void voreinst(); };
#endif
und die dazugehoerige option.cpp:
#include "optionwidget.h" #include <qtabdialog.h> #include <qlayout.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qdir.h> #include <qtextstream.h> #include <qsettings.h>
#ifndef Q_WS_WIN #define dir "/home/rico/.adress" #define adrfile "/home/rico/.adress/adr.dat" #define conffile "/home/rico/.adress/conf.dat"
#else #define dir "c:\" #define adrfile "c:\adr.dat" #define conffile "c:\conf.dat" #endif
OptionDialog::OptionDialog(QWidget *parent, const char *name, WFlags f): QWidget (parent, name, f){ setCaption("Grundeinstellungen"); QGridLayout *g = new QGridLayout(this,9,3); QLabel *l = new QLabel("Einstellungen", this); QLabel *l1 = new QLabel("Ausgangsserver",this); QLabel *l2 = new QLabel("(meist pop.irgendwas.de)", this); QLabel *l3 = new QLabel("Eingangsserver", this); QLabel *l4 = new QLabel("(meist mail.irgendwas.de)", this); QLabel *l5 = new QLabel("Benutzer", this); QLabel *l6 = new QLabel("Password", this); QLabel *l7 = new QLabel("Path zur Adressdatei", this); QLabel *l8 = new QLabel("Maildatei-Eingang", this); QLabel *l9 = new QLabel("Maildatei-Ausgang", this); lmailserv = new QLineEdit(this); lpopserv = new QLineEdit(this); luser = new QLineEdit(this); lpassword = new QLineEdit(this); lpassword->setEchoMode(QLineEdit::Password); lpath = new QLineEdit(this); lmaildat = new QLineEdit(this); lamaildat = new QLineEdit(this); QPushButton *ok = new QPushButton("Ok", this); QPushButton *vor = new QPushButton("Voreinstellung", this); QPushButton *ch = new QPushButton("Abbrechen", this); QPushButton *sicht = new QPushButton("Sichtschutz", this); QObject::connect(sicht,SIGNAL(clicked()), this, SLOT(schaltesicht())); QObject::connect(ch,SIGNAL(clicked()),this,SLOT(hide())); QObject::connect(ok,SIGNAL(clicked()),this,SLOT(sichereconf())); QObject::connect(vor,SIGNAL(clicked()),this, SLOT(voreinst())); g->addWidget(l,0,1);
g->addWidget(l1,1,0); g->addWidget(l2,1,1); g->addWidget(lmailserv,1,2);
g->addWidget(l3,2,0); g->addWidget(l4,2,1); g->addWidget(lpopserv,2,2);
g->addWidget(l5,3,0); g->addWidget(luser,3,2);
g->addWidget(l6,4,0); g->addWidget(sicht,4,1); g->addWidget(lpassword,4,2);
g->addWidget(l7,5,0); g->addWidget(lpath,5,2);
g->addWidget(l8,6,0); g->addWidget(lmaildat,6,2);
//g->addWidget(l9,7,0); //g->addWidget(lamaildat,7,2);
g->addWidget(ok,8,0); g->addWidget(vor,8,1); g->addWidget(ch,8,2);
g->activate(); ladeconf(); }
void OptionDialog::ladeconf() {QSettings settings; lmailserv->setText(settings.readEntry("/Adress/Server/Mailserv")); lpopserv->setText(settings.readEntry("/Adress/Server/Popserv")); luser->setText(settings.readEntry("/Adress/Userspec/User")); lpassword->setText(settings.readEntry("/Adress/Userspec/Password")); lpath->setText(settings.readEntry("/Adress/Path/lpath")); lmaildat->setText(settings.readEntry("/Adress/Path/mpath")); lamaildat->setText(settings.readEntry("/Adress/Path/mapath")); } void OptionDialog::sichereconf() {QSettings settings; settings.writeEntry("/Adress/Server/Mailserv", lmailserv->text()); settings.writeEntry("/Adress/Server/Popserv", lpopserv->text()); settings.writeEntry("/Adress/Userspec/User", luser->text()); settings.writeEntry("/Adress/Userspec/Password", lpassword->text()); settings.writeEntry("/Adress/Path/lpath", lpath->text()); settings.writeEntry("/Adress/Path/mpath", lmaildat->text()); settings.writeEntry("/Adress/Path/mapath", lamaildat->text()); emit geaendert(lpath->text()); this->hide(); }
void OptionDialog::schaltesicht() { (lpassword->echoMode() == 2) ? lpassword->setEchoMode(QLineEdit::Normal):lpassword->setEchoMode(QLine Edit::Password); }
void OptionDialog::voreinst() { lpath->setText(adrfile); }
kann mir bitte wer verraten, warum ich denn nen "Segmentation fault " bekomm?
ps: bis zu ner bestimmten anzahl von Labels und LineEdits gings gut Ohne "Sf"...