You are not logged in.
Pages: 1
I found this website http://doc.trolltech.com/3.0/t1.html which shows how to write a hello world programme using QT. I wanted to try it out myself but ran into these errors (among others),
hi.c:1:26: error: qapplication.h: No such file or directory
hi.c:2:25: error: qpushbutton.h: No such file or directory
I've got qt 4.5 but figure I need the development package. However, I cannot seem to find qt-devel on any of the Arch Linux Repos... Is there some other package that is used for these C headers?
Last edited by tony5429 (2009-03-29 03:10:31)
Offline
Oh; good catch. Well rather than learn how to use qt3, I'll look for a qt 4.5 hello world website. Thanks!
Offline
The Qt hello world programme on wikipedia works fine:
#include <QtGui/QApplication>
#include <QtGui/QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel label("Hello, world!");
label.show();
return app.exec();
}
Thanks.
Offline
Well I'd like to have a button in the programme which allows the user to close the window. However, I find that the button is going on a separate window. Any ideas as to how to make the button on the same window as the "Hello world"?
#include <QApplication>
#include <QLabel>
#include <QPushButton>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QLabel label("Hello world!");
label.show();
QPushButton *button = new QPushButton("Close the window.");
QObject::connect(button, SIGNAL(clicked()), &app, SLOT(quit()));
button->show();
return app.exec();
}
Offline
Moving to "General Programming Forum"...
Offline
You are looking for something like this:
#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QWidget *window = new QWidget();
QVBoxLayout *layout = new QVBoxLayout();
QLabel *label = new QLabel("Hello world!");
QPushButton *button = new QPushButton("Close the window.");
QObject::connect(button, SIGNAL(clicked()), &app, SLOT(quit()));
layout->addWidget(label);
layout->addWidget(button);
window->setLayout(layout);
window->show();
return app.exec();
}
Offline
Perfect; thanks!
Offline
Pages: 1