HILFE!! was mach ich falsch?
Verfasst: 28. September 2007 16:08
Hallo.. ich habe in den letzten Tagen mit Qt-Programmierung angefangen. Ich kann schon eine Form im designer machen und das ganze compilieren... aber mehr auch nicht. (naja Grundkenntnisse von C++ hab ich).. Ich habe nun einen Button und wenn ich draufklicke soll in der Konsole die Meldung "Button pressed" erscheinen.. aber das klappt nicht
2007.cpp
test2007.h
Was mach ich falsch? 
2007.cpp
Code: Alles auswählen
#include <qapplication.h>
#include <iostream>
#include "test2007.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *window = new QWidget;
Ui::Form ui;
ui.setupUi(window);
window->show();
return app.exec();
}
void Ui_Form::testaktion() {
std::cout << "Button pressed";
}
Code: Alles auswählen
/********************************************************************************
** Form generated from reading ui file 'test2007.ui'
**
** Created: Fri Sep 28 15:47:28 2007
** by: Qt User Interface Compiler version 4.2.3
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
#ifndef UI_TEST2007_H
#define UI_TEST2007_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
class Ui_Form
{
public:
QPushButton *pushButton;
QPushButton *pushButton_2;
void setupUi(QWidget *Form)
{
Form->setObjectName(QString::fromUtf8("Form"));
pushButton = new QPushButton(Form);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(10, 10, 231, 121));
pushButton_2 = new QPushButton(Form);
pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
pushButton_2->setGeometry(QRect(240, 160, 141, 81));
retranslateUi(Form);
QSize size(414, 282);
size = size.expandedTo(Form->minimumSizeHint());
Form->resize(size);
QObject::connect(pushButton, SIGNAL(clicked()), Form, SLOT(close()));
QObject::connect(pushButton_2, SIGNAL(clicked()), Form, SLOT(testaktion()));
QMetaObject::connectSlotsByName(Form);
} // setupUi
void retranslateUi(QWidget *Form)
{
Form->setWindowTitle(QApplication::translate("Form", "Form", 0, QApplication::UnicodeUTF8));
pushButton->setText(QApplication::translate("Form", "Dr\303\274ck mich!!!", 0, QApplication::UnicodeUTF8));
pushButton_2->setText(QApplication::translate("Form", "Mich auch!!!", 0, QApplication::UnicodeUTF8));
Q_UNUSED(Form);
} // retranslateUi
public slots:
void testaktion();
};
namespace Ui {
class Form: public Ui_Form {};
} // namespace Ui
#endif // UI_TEST2007_H