In need of an advice of simple line drawing with Qt
Hello!
I am a complete newbie what comes to Qt C++ programming. My assignment would be to draw a simple line in a QWidget and frankly I don't know what all I ought to be aware of (header files, QObject...etc) in order to complete this task. I am sorry if this question is answered elsewhere on the forum, yet I couldn't find a solution from here or any Qt related forums nor the Web. I am using QT 4.6.2 and a Qt Creator 1.3.1 on Windows Vista.
I have a designer form, in which I have promoted a class "paint" and created after a header file "paint.h"
The header file (paint.h) looks like:
Code:
#ifndef PAINT_H
#define PAINT_H
#include <QWidget>
{
Q_OBJECT
public:
protected:
};
#endif // PAINT_H
and I have a source file:
Code:
#include "paint.h"
#include <QApplication>
#include <QPainter>
#include <QLineF>
{
QLineF line
(10.0,
80.0,
90.0,
20.0);
painter.drawLine(line);
}
Yet this wholeness is invalid and I'm not sure what things are wrong with this. The compiler output looks as following:
Code:
.../harjoitus2/draw_line/line1.cpp:7: warning: 'virtual void QWidget::paintEvent(QPaintEvent*)' redeclared without dllimport attribute: previous dllimport ignored
c:\Qt\2010.02.1\qt\lib/libqtmaind.a:-1: error: In function `WinMain@16':
C:\qt-greenhouse\Trolltech\Code_less_create_more\Trolltech\Code_less_create_more\Troll\4.6\qt\src\winmain/qtmain_win.cpp:131: undefined reference to `qMain(int, char**)'
:-1: error: collect2: ld returned 1 exit status
I would be very grateful if you would point me out the essential facts of making this simple program to function. Thanks in advance! :)
Re: In need of an advice of simple line drawing with Qt
It should be paint::paintEvent(...) in line #7 of the second code snippet.
Re: In need of an advice of simple line drawing with Qt
Thanks for your reply!
I corrected the line #7, but yet I get these error messages:
Code:
c:\Qt\2010.02.1\qt\lib/libqtmaind.a:-1: error: In function `WinMain@16':
C:\qt-greenhouse\Trolltech\Code_less_create_more\Trolltech\Code_less_create_more\Troll\4.6\qt\src\winmain/qtmain_win.cpp:131: undefined reference to `qMain(int, char**)'
:-1: error: collect2: ld returned 1 exit status
Re: In need of an advice of simple line drawing with Qt
Did you implement the main() function in your program? Be sure to add the file containing it to your project.
Re: In need of an advice of simple line drawing with Qt
Yes, I did it now and the program works as espected. Thanks for your help. :)