
Originally Posted by
u04f061
i am new user of qt and i am running ubuntu dapper linux.i got this hello world programe from trolltech official site. i could not run this programe. i got an error.here it is
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );
hello.show();
return a.exec();
}
ror 1
QApplication is not a widget remove line a.setMainWidget( &hello ); or insert a widged..
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
label.show();
return a.exec();
}
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel label("Hallo Welt!");
label.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
or ....
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
button.show();
QObject::connect(&button,
SIGNAL(clicked
()),
&a, SLOT(quit()));
return a.exec();
}
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton button("Beenden");
button.show();
QObject::connect(&button, SIGNAL(clicked()),
&a, SLOT(quit()));
return a.exec();
}
To copy to clipboard, switch view to plain text mode
or... ++ QWidget window;
#include <QApplication>
#include <QVBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QSlider>
int main(int argc, char *argv[])
{
mainLayout->addWidget(label);
mainLayout->addWidget(spinBox);
mainLayout->addWidget(slider);
QObject::connect(spinBox,
SIGNAL(valueChanged
(int)),
label, SLOT(setNum(int)));
QObject::connect(spinBox,
SIGNAL(valueChanged
(int)),
slider, SLOT(setValue(int)));
QObject::connect(slider,
SIGNAL(valueChanged
(int)),
label, SLOT(setNum(int)));
QObject::connect(slider,
SIGNAL(valueChanged
(int)),
spinBox, SLOT(setValue(int)));
window.show();
return a.exec();
}
#include <QApplication>
#include <QVBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QSlider>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget window;
QVBoxLayout* mainLayout = new QVBoxLayout(&window);
QLabel* label = new QLabel("0");
QSpinBox* spinBox = new QSpinBox;
QSlider* slider = new QSlider(Qt::Horizontal);
mainLayout->addWidget(label);
mainLayout->addWidget(spinBox);
mainLayout->addWidget(slider);
QObject::connect(spinBox, SIGNAL(valueChanged(int)),
label, SLOT(setNum(int)));
QObject::connect(spinBox, SIGNAL(valueChanged(int)),
slider, SLOT(setValue(int)));
QObject::connect(slider, SIGNAL(valueChanged(int)),
label, SLOT(setNum(int)));
QObject::connect(slider, SIGNAL(valueChanged(int)),
spinBox, SLOT(setValue(int)));
window.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks