bin grade dabei mich in QT einzuarbeiten und hab mir nen sinnloses Progamm geschrieben, das Text aus einem TextEdit Widget in ein anderes TextEdit Widget kopiert.
Wollte damit eigene Slots testen . Aber meine eigenen Slots laufen nicht und ich hab keine Ahnung warum.
hier mein Code
test.h
Code: Alles auswählen
#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
#include <QTextEdit>
#include <QTextStream>
#include <QString>
#include <QObject>
class haupt : public QMainWindow
{
private:
Q_OBJECT
public:
haupt ();
QString str;
QString *str_ptr;
};
class texte :public QTextEdit
{
private:
Q_OBJECT
public:
texte(QString, QWidget*);
public slots:
void cp_string(QString *);
void sh_string(QString *);
};
Code: Alles auswählen
#include <test.h>
haupt::haupt()
{
setGeometry(20,20,600,600);
QPushButton *send = new QPushButton(tr("Send"),this);
QPushButton *receive = new QPushButton(tr("Receive"),this);
texte *text = new texte(tr("Hallo"),this);
texte *text2 = new texte(tr(""),this);
send->setGeometry(500,50,75,25);
receive->setGeometry(500,100,75,25);
text->setGeometry(20,50,75,75);
text2->setGeometry(20,150,75,75);
text->cp_string(&str);
text2->sh_string(&str);
connect(send,SIGNAL(clicked()),text,SLOT(cp_string(&str)));
connect(receive,SIGNAL(clicked()),text2,SLOT(sh_string(&str)));
}
// VerboseObject( QObject *parent=0, char *name=0 ) : QObject( parent, name )
texte::texte(QString name, QWidget *parent) : QTextEdit(name , parent)
{
QTextEdit();
}
void texte::cp_string(QString *str2_ptr)
{
*str2_ptr=toPlainText();
}
void texte::sh_string(QString *str2_ptr)
{
setPlainText(*str2_ptr);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
haupt hp;
hp.show();
return app.exec();
}