Seite 1 von 1

Zweites Formular aus Hauptfenster aufrufen, nichts klappt

Verfasst: 7. April 2009 17:45
von Der Mann aus der Kugel
Hi,

ich habe eine Anwendung mit folgendem Code

main.cpp:

Code: Alles auswählen

//--- main.cpp - start ---
 
#include "Plan3x.h"
#include "NeuesZiel.h"
#include <QApplication>
#include <QMainWindow>
#include <QProcess>
#include <QWidget>

int main( int argc, char* argv[]){

	QApplication a(argc, argv);
	Plan3x w;
	w.show();

	return a.exec();
}
Plan3x.h:

Code: Alles auswählen

#ifndef Plan3x_H
#define Plan3x_H
 
#include "ui_Plan3x.h"
 
class Plan3x : public QMainWindow, public Ui::MainWindow{
	Q_OBJECT
 
	public:
		Plan3x (QMainWindow *parent = 0);
		~Plan3x();

	private slots:

	void mousePressEvent( QMouseEvent* event );
	void mouseMoveEvent( QMouseEvent* event );
	void mouseReleaseEvent( QMouseEvent* event );

//etc. hier sind halt diverse slots

	

};
#endif //Plan3x_H

und Plan3x.cpp, das auch resource ist:

Code: Alles auswählen

#include "math.h"
#include <QProcess> 
#include <QFileDialog> 
#include <QMessageBox> 
#include <QImage>
#include <QPixmap>
#include <QWidget>
#include <QPainter>
#include <QTimer>
#include <QtGui>
#include <QWidget>
#include <QApplication>    
#include "Plan3x.h"
#include "NeuesZiel.h"


Plan3x::Plan3x(QMainWindow *parent) : QMainWindow(parent){
	setupUi(this);

	connect(actionNeu, SIGNAL (triggered()), this, SLOT(neues_projekt()));
	connect(action_ffnen, SIGNAL (triggered()), this, SLOT(projekte_oeffnen()));
	connect(actionSpeichern, SIGNAL (triggered()), this, SLOT(speichern()));


	connect(zoomen, SIGNAL(valueChanged(int)), zoomstufe, SLOT(setNum(int)));
	connect(zoomen, SIGNAL(valueChanged(int)), this, SLOT(karte_ausschneiden()));


}
 
Plan3x::~Plan3x(){
}


void Plan3x::plausibilitaet_pruefen() {

	close();
}
//etc. die funktionen halt

void Plan3x::neues_ziel() {

	QWidget *widget = new QWidget;
	Ui_NeuesZiel::Ui_NeuesZiel ui3;
     	ui3.setupUi(widget);
	widget->show();

}
jetzt passiert folgendes: man kann mit neues_ziel() über das menü halt den neuen dialog öffnen.

ich hab leider total den überblick verloren: jetzt muss ich doch irgendwo dessen slots und signale und funktionen ablegen oder? leider kommt gar nichst an, kann mir jemand das mal erklären

ich weiß verraffter post aber ich sitze schon seit stunden dran und kann nicht mehr so gut denken 8) [/code]

Verfasst: 7. April 2009 20:56
von upsala

Code: Alles auswählen

   QWidget *widget = new QWidget; 
    Ui_NeuesZiel::Ui_NeuesZiel ui3; 
         ui3.setupUi(widget); 
    widget->show(); 
Du solltest diesen Teil erst mal in eine eigene Klasse verpacken, um wieder Überblick zu bekommen.