Entschuldige das ich mich erst jetzt melde, ich habe jetzt mal ein bisschen damit rumgespielt, aber es immer noch nicht herraus gefunden. Hier mal mein Code:
on_pb_addProfile_clicked() öffnet den zweiten Dialog mit einem Pointer auf this.
updateProfile() wird von dem zweiten Dialog benutzt, um Items in die ComboBox zu setzen
(MainLogin.cpp)
Code: Alles auswählen
#include "mainlogin.h"
#include "ui_mainlogin.h"
#include <QDebug>
MainLogin::MainLogin(QWidget *parent) :
QDialog(parent),
ui(new Ui::MainLogin)
{
ui->setupUi(this);
ui->pb_logout->setEnabled(false);
ui->le_passwd->setEchoMode(QLineEdit::Password);
ui->pb_login->setDefault(true);
}
MainLogin::~MainLogin()
{
delete ui;
}
void MainLogin::on_pb_addProfile_clicked()
{
QString strProfile = "str";
qDebug() << "Adresse von strProfile: " << &strProfile;
addProfile *ap = new addProfile(0, this);
ap->show();
}
void MainLogin::updateProfile(QString profileName)
{
ui->cb_profile->addItem(profileName);
}
Der Zweite Dialog, im Konstruktor der Pointer auf MainLogin
(addprofile.h)
Code: Alles auswählen
#ifndef ADDPROFILE_H
#define ADDPROFILE_H
#include <QDialog>
#include <QDebug>
#include "mainlogin.h"
namespace Ui {
class addProfile;
}
class addProfile : public QDialog
{
Q_OBJECT
public:
explicit addProfile(QWidget *parent, MainLogin* getProfile);
~addProfile();
QString* strptr2;
MainLogin* setProfile;
private slots:
void on_pb_abort_clicked();
void on_pb_ok_clicked();
private:
Ui::addProfile *ui;
};
#endif // ADDPROFILE_H
Über on_pb_ok_clicked(), wird aus einer LineEdit den QString in der Funktion updateProfile zum MainLogin übergeben.
(addprofile.cpp)
Code: Alles auswählen
#include "addprofile.h"
#include "ui_addprofile.h"
addProfile::addProfile(QWidget *parent, MainLogin* getProfile) :
QDialog(parent),
ui(new Ui::addProfile)
{
ui->setupUi(this);
setProfile = getProfile;
}
addProfile::~addProfile()
{
delete ui;
}
void addProfile::on_pb_abort_clicked()
{
exit(-1);
}
void addProfile::on_pb_ok_clicked()
{
setProfile->updateProfile(ui->le_profile->text());
}
Das alles jedenfalls in der Theorie
Der Compiler gibt mir jedoch zwei Fehler bei AddProfile. Dort wird gesagt, das MainLogin nicht declaniert ist.
Hier mal die Compilermeldung:
Die Zeile ist beim Konstruktor von AddProfile
Code: Alles auswählen
C:\Users\musteruser\Desktop\C++\QT\Projects\Sql-Schulplaner\Sql-Schulplaner\addprofile.h:17: Fehler:'MainLogin' has not been declared
explicit addProfile(QWidget *parent, MainLogin* getProfile);
^
Und hier die zweite Meldung:
Das ist bei MainLogin* setProfile in AddProfile.h
Code: Alles auswählen
C:\Users\musteruser\Desktop\C++\QT\Projects\Sql-Schulplaner\Sql-Schulplaner\addprofile.h:20: Fehler:'MainLogin' does not name a type
MainLogin* setProfile;
^