ich schaffe es nicht ein Signal eines QPushButton mit einem Slot meiner Klasse zu verbinden.
Ich hätte gerne, dass beim klicken auf diesen Button ein neues Fenster auf geht.
Das Hauptfenster habe ich im Designer erstellt und von der erzeugten Klasse meine eigene abgeleitet. Dann habe ich das zweite Fenster auch im Designer erstellt und habe wieder meine Klasse von der erstellten abgeleitet.
Jetzt möchte ich eigentlich in einem Slot des Hauptfensters den Construktor
des zweiten Fensters aufrufen.
Hier ist meine Header des Hauptfensters:
Code: Alles auswählen
#ifndef MY_MAIN_WINDOW_H_
#define MY_MAIN_WINDOW_H_
#include "my_info_window.h"
#include <QtCore>
#include <QtGui>
class my_main_window : private Ui_MainWindow
{
Q_OBJECT
public:
my_main_window(QMainWindow *MainWindow);
void connect_slots(QApplication *app);
QPushButton *new_Projekt_button;
QPushButton *open_existing_Projekt_button;
QPushButton *new_tga_Schema_button;
QPushButton *back_button;
QPushButton *copy_button;
QPushButton *cut_button;
QPushButton *paste_button;
QPushButton *delete_button;
QSpacerItem *toolbarspacer;
QPushButton *help_button;
QPushButton *exit_button;
my_info_window *info;
QDialog dialog;
public slots:
void quit();
void show_info_dialog(void);
};
#endif /*MY_MAIN_WINDOW_H_*/
Code: Alles auswählen
#include "my_main_window.h"
#include "my_info_window.h"
#include "ui_MOBILA_main_window.h"
#include <QtCore>
#include <QtGui>
#include <stdlib.h>
#include <stdio.h>
my_main_window::my_main_window(QMainWindow *MainWindow)
{
setupUi(MainWindow);
this->label_fortschritt->setPixmap(QPixmap(":bilder/icons/32x32/actions/button_ok.png"));
//Buttons Toolbar
new_Projekt_button = new QPushButton();
new_Projekt_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/mimetypes/mime_empty.png")));
new_Projekt_button->setToolTip("Neues Projekt eröffnen");
open_existing_Projekt_button = new QPushButton();
open_existing_Projekt_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/fileopen.png")));
open_existing_Projekt_button->setToolTip("vorhandenes Projekt öffnen");
new_tga_Schema_button = new QPushButton();
new_tga_Schema_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/apps/plan.svg")));
new_tga_Schema_button->setToolTip("neues TGA-Schema zum Projekt hinzufügen");
back_button = new QPushButton();
back_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/back.png")));
back_button->setToolTip("rückgängig machen");
copy_button = new QPushButton();
copy_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/editcopy.png")));
copy_button->setToolTip("kopieren");
cut_button = new QPushButton();
cut_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/editcut.png")));
cut_button->setToolTip("ausschneiden");
paste_button = new QPushButton();
paste_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/editpaste.png")));
paste_button->setToolTip("einfügen");
delete_button = new QPushButton();
delete_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/editdelete.png")));
delete_button->setToolTip("löschen");
toolbarspacer = new QSpacerItem(20, 101, QSizePolicy::Minimum, QSizePolicy::Expanding);
help_button = new QPushButton();
help_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/help.png")));
help_button->setToolTip("Hilfe");
exit_button = new QPushButton();
exit_button->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/exit.png")));
exit_button->setToolTip("Programm schließen");
this->toolBar->addWidget(new_Projekt_button);
this->toolBar->addWidget(open_existing_Projekt_button);
this->toolBar->addWidget(new_tga_Schema_button);
this->toolBar->addSeparator();
this->toolBar->addWidget(back_button);
this->toolBar->addWidget(copy_button);
this->toolBar->addWidget(cut_button);
this->toolBar->addWidget(paste_button);
this->toolBar->addWidget(delete_button);
this->toolBar->addSeparator();
this->toolBar->addWidget(help_button);
this->toolBar->addWidget(exit_button);
//Menüs
this->actionNeues_Projekt->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/mimetypes/mime_empty.png")));
this->actionvorhandeneProjekte->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/fileopen.png")));
this->actionTGA_Schema_hinzuf_gen->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/apps/plan.svg")));
this->actionSpeichern->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/filesave.png")));
this->actionAlle_speichern->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/filesaveall.png")));
this->actionSpeichern_als->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/filesaveas.png")));
this->actionProgramm_beenden->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/exit.png")));
this->actionR_ckg_ngig->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/back.png")));
this->actionKopieren->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/editcopy.png")));
this->actionAusschneiden->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/editcut.png")));
this->actionEinf_gen->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/editpaste.png")));
this->actionL_schen->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/editdelete.png")));
this->actionHilfe->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/help.png")));
this->action_ber_MOBILA->setIcon(QIcon(QString::fromUtf8(":bilder/icons/32x32/actions/messagebox_info.png")));
}
void my_main_window::connect_slots(QApplication *app)
{
QObject::connect(this->actionProgramm_beenden, SIGNAL( triggered() ), app , SLOT( quit() ) );
QObject::connect(this->exit_button, SIGNAL( clicked () ), app , SLOT( quit() ) );
//////////////////////////////////////////////////////////////////////
//// Achtung : das hier klappt nicht
/////////////////////////////////////////////////////////////////////
QObject::connect((this->help_button), SIGNAL( clicked () ), (this) , SLOT( show_info_dialog() ) );
}
void my_main_window::show_info_dialog()
{
printf("sdfdsfsdf");
info = new my_info_window();
}
Gruß,
SuperSonik