Re: [SLUG] Qt compiling

From: Ed Centanni (ecentan1@tampabay.rr.com)
Date: Sat Jun 14 2003 - 15:00:17 EDT


Qt requires that source code be pre-processed by the Qt Meta Object
Compiler (moc) before being sent to gcc. You also need to set the
QT_DIR environment variable to point to the Qt root directory (export
QT_DIR=/usr/lib/qt3 in your case). Do this FIRST.

The simplest way to start a Qt project is to cd to the project directory
that contains your .cpp file(s), use "qmake -project" to create a
project file. Qmake will look at all the headers and source in the
directory and figure it all out. The project file will be named
<current dir>.pro. Then use "qmake" without arguments to create a
Makefile based on the configuration in the project file. Now all you
need to do is type "make" and enjoy. If you need to add more files to
the project, edit the .pro and type "qmake" to re-create the Makefile.

See the QT documentation ( type "assistant" at the command line) for
more details.

Also your QLabel constructor is wrong. Change the line:
    QLabel* mylabel = new QLabel( "Hello World" );

to

    QLabel* mylabel = new QLabel(NULL, "Hello World" );

Ed.

Frank Roberts - SOTL wrote:

> Hi All
>
> I have Md 9.1 installed on my Thinkpad which eliminates most of the issues
> that I had with Md 9.0. In that light I have just tried the copy command with
> the following code and I will say thi much the new copy command is awsom.
>
> Currently, I am trying to set up the Qt compiler so that I may again attempt
> to start to learn a little bit of programming.
>
> -----
> In that light I have located Qt to be in the following directory.
>
> bash-2.05b$ locate bin/designer
> /usr/lib/qt3/bin/designer-real
> /usr/lib/qt3/bin/designer
> /usr/bin/designer-qt3
>
> -----
>>From the above I adjusted the complier parameters to be as follows:
> gcc -I/usr/lib/qt3/include -L/usr/lib/qt3/lib -lqt -o
> helloworld Helloworld.cpp
>
> -----
> The Helloworld program which was copied from Worx's site of example files for
> the O'Reilly "Programming with Qt" book follows: This is identical line for
> line the program shown on paper in the book so it should be correct.
>
> #include <qapplication.h>
> #include <qlabel.h>
>
> int main( int argc, char* argv[] )
> {
> QApplication myapp( argc, argv );
>
> QLabel* mylabel = new QLabel( "Hello World" );
> mylabel->resize( 80, 30 );
>
> myapp.setMainWidget( mylabel );
> mylabel->show();
> return myapp.exec();
> }
>
> -----
> When I attempt to complile I get the following:
>
> helloworld.cpp: In function `int main(int, char**)':
> helloworld.cpp:8: no matching function for call to `
> QLabel::QLabel(const char[12])'
> /usr/lib/qt3/include/qlabel.h:162: candidates are:
> QLabel::QLabel(const QLabel&)
> /usr/lib/qt3/include/qlabel.h:65: QLabel::QLabel(QWidget*,
> const QString&, QWidget*, const char* = 0, unsigned int = 0)
> /usr/lib/qt3/include/qlabel.h:63: QLabel::QLabel(const
> QString&, QWidget*, const char* = 0, unsigned int = 0)
> /usr/lib/qt3/include/qlabel.h:61: QLabel::QLabel(QWidget*,
> const char* = 0, unsigned int = 0)
>
> -----
> My assumption is I do not have the gcc complile parameters correct.
> I would appreciate it if anybody sees the problem and could furnish a wee bit
> of guidance.
>
> Thanks
> Frank
>
>
>
>
>
>
>
>
>
>
>



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:42:11 EDT