basti1985
30-09-2007, 21:37
ich bin gerade dabei mich mit qt4 zu beschäftigen soweit sogut,
doch mit der parameter übergabe hapert es noch etwas...
ich wollte das fenster in diesem code:
#include <QtGui/QApplication>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
#include <QtGui/QFont>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(200, 100);
QLabel label("Hello World!", &window);
label.setGeometry(0, 0, 200, 50);
label.setAlignment(Qt::AlignCenter);
label.setFont(QFont("Arial", 20, QFont::Bold));
QPushButton button("Close", &window);
button.setGeometry(10, 60, 180, 30);
QObject::connect(&button, SIGNAL(clicked()), &window, SLOT(close()));
window.show();
return app.exec();
}
in eine eigene funktion schreiben also etwa so
#include <QtGui/QApplication>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
#include <QtGui/QFont>
window()
{
QApplication app(argc, argv);
QWidget window;
window.resize(200, 100);
QLabel label("Hello World!", &window);
label.setGeometry(0, 0, 200, 50);
label.setAlignment(Qt::AlignCenter);
label.setFont(QFont("Arial", 20, QFont::Bold));
QPushButton button("Close", &window);
button.setGeometry(10, 60, 180, 30);
QObject::connect(&button, SIGNAL(clicked()), &window, SLOT(close()));
window.show();
return app.exec();
}
int main(int argc, char *argv[])
{
window();
return 0;
}
doch wie übergebe ich argc und argv an window ??
bzw. was ist hier falsch ??
doch mit der parameter übergabe hapert es noch etwas...
ich wollte das fenster in diesem code:
#include <QtGui/QApplication>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
#include <QtGui/QFont>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(200, 100);
QLabel label("Hello World!", &window);
label.setGeometry(0, 0, 200, 50);
label.setAlignment(Qt::AlignCenter);
label.setFont(QFont("Arial", 20, QFont::Bold));
QPushButton button("Close", &window);
button.setGeometry(10, 60, 180, 30);
QObject::connect(&button, SIGNAL(clicked()), &window, SLOT(close()));
window.show();
return app.exec();
}
in eine eigene funktion schreiben also etwa so
#include <QtGui/QApplication>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
#include <QtGui/QFont>
window()
{
QApplication app(argc, argv);
QWidget window;
window.resize(200, 100);
QLabel label("Hello World!", &window);
label.setGeometry(0, 0, 200, 50);
label.setAlignment(Qt::AlignCenter);
label.setFont(QFont("Arial", 20, QFont::Bold));
QPushButton button("Close", &window);
button.setGeometry(10, 60, 180, 30);
QObject::connect(&button, SIGNAL(clicked()), &window, SLOT(close()));
window.show();
return app.exec();
}
int main(int argc, char *argv[])
{
window();
return 0;
}
doch wie übergebe ich argc und argv an window ??
bzw. was ist hier falsch ??