Results 1 to 4 of 4

Thread: Compilation failed ... I don't know why :(

  1. #1
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Compilation failed ... I don't know why :(

    Hi,

    I am pretty newbie in developpement so my mistake should be easy to find out, but not for me.

    I have picked up some line of code in order do develop a simple custom widget but the compilation failed.

    For the .h
    #include <qwidget.h>

    class QLineEdit;
    class QPushButton;

    class FileChooser : public QWidget
    {
    Q_OBJECT
    Q_ENUMS( Mode )
    Q_PROPERTY( Mode mode READ mode WRITE setMode )
    Q_PROPERTY( QString fileName READ fileName WRITE setFileName )

    public:
    FileChooser( QWidget *parent = 0, const char *name = 0);
    enum Mode { File, Directory };
    QString fileName() const;
    Mode mode() const;

    public slots:
    void setFileName( const QString &fn );
    void setMode( Mode );

    signals:
    void fileNameChanged( const QString & );

    private slots:
    void chooseFile();

    private:
    QLineEdit *lineEdit;
    QPushButton *button;
    Mode md;
    };

    For the .cpp
    #include "filechooser.h"
    #include "qlayout.h"
    #include <qlineedit.h>
    #include <qpushbutton.h>
    #include <qfiledialog.h>

    FileChooser::FileChooser( QWidget *parent, const char *name )
    : QWidget( parent, name ), md( File )
    {
    QHBoxLayout *layout = new QHBoxLayout( this );
    layout->setMargin( 0 );

    lineEdit = new QLineEdit( this, "filechooser_lineedit" );
    layout->addWidget( lineEdit );
    connect( lineEdit, SIGNAL( textChanged( const QString & ) ), this,
    SIGNAL( fileNameChanged( const QString & ) ) );

    button = new QPushButton( "...", this, "filechooser_button" );
    button->setFixedWidth( button->fontMetrics().width( " ... " ) );
    layout->addWidget( button );

    connect( button, SIGNAL( clicked() ), this, SLOT( chooseFile() ) );
    setFocusProxy( lineEdit );
    }

    void FileChooser::setFileName( const QString &fn )
    {
    lineEdit->setText( fn );
    }

    QString FileChooser::fileName() const
    {
    return lineEdit->text();
    }

    Mode FileChooser::mode() const
    {
    return md;
    }

    void FileChooser::setMode( Mode m )
    {
    md = m;
    }

    void FileChooser::chooseFile()
    {
    QString fn;

    if( mode() == File )
    fn = QFileDialog::getOpenFileName( lineEdit->text(), QString::null, this );
    else
    fn = QFileDialog::getExistingDirectory( lineEdit->text(), this);

    if ( !fn.isEmpty() )
    {
    lineEdit->setText( fn );
    emit fileNameChanged( fn );
    }
    }

    So here is the code ... could someone help me plese ?

  2. #2
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Compilation failed ... I don't know why :(

    Replace
    Qt Code:
    1. #include "qlayout.h"
    To copy to clipboard, switch view to plain text mode 
    with
    Qt Code:
    1. #include <qlayout.h>
    To copy to clipboard, switch view to plain text mode 
    You should also post the error(s) that the compiler presented.
    Finally please, please use the [C O D E] tags around your sources

  3. #3
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Compilation failed ... I don't know why :(

    Thanks, it is ok now.

    Next time I'll use the code tags.

    Is there a way to put a [SOLVE] tag in the title message once the problem is solved ? (I've seen that on other forums, it's quite cool to only focus on specific messages, those that are not solved yet).

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Compilation failed ... I don't know why :(

    Quote Originally Posted by yellowmat
    Is there a way to put a [SOLVE] tag in the title message once the problem is solved ?
    You could try to edit your first post, but I'm not sure if it will work (vBulletin distinguishes between thread title and first post title).

Similar Threads

  1. QT Extended Installation Problem
    By qoo in forum Installation and Deployment
    Replies: 1
    Last Post: 16th October 2008, 11:38
  2. Qt 4.4.0 installation failed!!!!!
    By biswajithit in forum Installation and Deployment
    Replies: 1
    Last Post: 4th August 2008, 15:38
  3. Qt 4,4 on Solaris 10 compilation error
    By ToddAtWSU in forum Installation and Deployment
    Replies: 2
    Last Post: 1st July 2008, 13:24
  4. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  5. X Error of failed request - on exit
    By VorosM in forum Newbie
    Replies: 3
    Last Post: 12th April 2006, 09:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.