Results 1 to 11 of 11

Thread: compile error that i don't understand

  1. #1
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Question compile error that i don't understand

    I have selected the lines relevant (sic) to the prolem:
    first archiv.h puis archiv.cpp

    Qt Code:
    1. class Archives : public QDialog
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. Archives( QWidget *parent = 0 );
    7. ~Archives();
    8.  
    9. protected:
    10. QTreeView *qArchiv;
    11.  
    12. void addArchiv( QString sDate, QString sDest, QString sMsg );
    13. void remplirArchiv();
    14. void selmsg( const QModelIndex() &);
    15.  
    16. QPushButton *pbOk;
    17. };
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. //****************************************************************
    2. connect( qArchiv, SIGNAL( clicked( const QModelIndex() ) ),
    3. this, SLOT( selmsg( const QModelIndex() ) ) );
    4. }
    5.  
    6. void Archives::selmsg( const QModelIndex() idx )
    7. {
    8. accept();
    9. close();
    10. }
    To copy to clipboard, switch view to plain text mode 
    compile:
    7 C:\Qt\test\sms\archiv.cpp In file included from archiv.cpp
    24 C:\Qt\test\sms\archiv.h variable or field `selmsg' declared void
    24 C:\Qt\test\sms\archiv.h expected `;' before '(' token
    60 C:\Qt\test\sms\archiv.cpp variable or field `selmsg' declared void
    60 C:\Qt\test\sms\archiv.cpp `int Archives::selmsg' is not a static member of `class Archives'
    60 C:\Qt\test\sms\archiv.cpp expected primary-expression before "const"
    Last edited by incapacitant; 29th March 2006 at 13:13.

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 80 Times in 74 Posts

    Default Re: compile error that i don't understand

    replace
    Qt Code:
    1. void selmsg( const QModelIndex() &);
    To copy to clipboard, switch view to plain text mode 
    by
    Qt Code:
    1. void selmsg( const QModelIndex &);
    To copy to clipboard, switch view to plain text mode 
    and

    replace
    Qt Code:
    1. void Archives::selmsg( const QModelIndex() idx )
    To copy to clipboard, switch view to plain text mode 
    by

    Qt Code:
    1. void Archives::selmsg( const QModelIndex &idx )
    To copy to clipboard, switch view to plain text mode 

    and then try to compile again

  3. The following user says thank you to munna for this useful post:

    incapacitant (29th March 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Default Re: compile error that i don't understand

    yes thanks now it compiles but the slot() won't close the window, ot i wonder if it's activated.

    Qt Code:
    1. ...
    2. connect( qArchiv, SIGNAL( clicked( const QModelIndex() ) ),
    3. this, SLOT( selmsg( const QModelIndex() ) ) );
    4. }
    5.  
    6. //****************************************************************
    7. void Archives::selectmsg( const QModelIndex &idx )
    8. {
    9. accept();
    10. close();
    11. }
    12. ..
    13.  
    14. qArchiv is a QTreeview that I want to select.
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Jan 2006
    Posts
    667
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 80 Times in 74 Posts

    Default Re: compile error that i don't understand

    replace

    Qt Code:
    1. connect( qArchiv, SIGNAL( clicked( const QModelIndex() ) ),
    2. this, SLOT( selmsg( const QModelIndex() ) ) );
    To copy to clipboard, switch view to plain text mode 

    by

    Qt Code:
    1. connect( qArchiv, SIGNAL( clicked( const QModelIndex &) ),
    2. this, SLOT( selmsg( const QModelIndex &) ) );
    To copy to clipboard, switch view to plain text mode 

    and then try.

  6. The following user says thank you to munna for this useful post:

    incapacitant (29th March 2006)

  7. #5
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Default Re: compile error that i don't understand

    connect( qArchiv, SIGNAL( clicked( QModelIndex &) ),
    this, SLOT( close() ) );
    thius won't even work !

  8. #6
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows
    Thanks
    9
    Thanked 27 Times in 27 Posts

    Default Re: compile error that i don't understand

    Signal and slot must have the same params
    a life without programming is like an empty bottle

  9. The following user says thank you to zlatko for this useful post:

    incapacitant (29th March 2006)

  10. #7
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Default Re: compile error that i don't understand

    Qt Code:
    1. connect( qArchiv, SIGNAL( clicked( QModelIndex &) ),
    2. this, SLOT( selectmsg( QModelIndex &) ) );
    3. }
    4. //****************************************************************
    5. void Archives::selectmsg( const QModelIndex &idx )
    6. {
    7. accept();
    8. close();
    9. }
    To copy to clipboard, switch view to plain text mode 

    does not close the dialog

  11. #8
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows
    Thanks
    9
    Thanked 27 Times in 27 Posts

    Default Re: compile error that i don't understand

    what about this?
    Qt Code:
    1. connect( qArchiv, SIGNAL( clicked( const QModelIndex &) ),
    2. this, SLOT( selectmsg( const QModelIndex &) ) );
    To copy to clipboard, switch view to plain text mode 
    a life without programming is like an empty bottle

  12. The following user says thank you to zlatko for this useful post:

    incapacitant (29th March 2006)

  13. #9
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Default Re: compile error that i don't understand

    Qt Code:
    1. // setupViews
    2. qArchiv = new QTreeView( this );
    3. qArchiv->resize( QSize( 330, 112 ) );
    4. qArchiv->move( 34, 71 );
    5. qArchiv->setModel(model);
    6. qArchiv->setEditTriggers( QAbstractItemView::NoEditTriggers );
    7. qArchiv->setSelectionMode( QListView::SingleSelection );
    8. qArchiv->header()->resizeSection( 0,110 );
    9.  
    10. QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
    11. qArchiv->setSelectionModel(selectionModel);
    12. qArchiv->setRootIsDecorated( false );
    13.  
    14. remplirArchiv();
    15.  
    16. // ok push button
    17. pbOk = new QPushButton( "Ok", this);
    18. pbOk->resize( QSize( 50, 20 ) );
    19. pbOk->move( 300, 190 );
    20.  
    21. connect( pbOk, SIGNAL( clicked() ), this, SLOT( close() ) );
    22. connect( qArchiv, SIGNAL( clicked( const QModelIndex &) ),
    23. this, SLOT( selectmsg( const QModelIndex &) ) );
    24. }
    25. //****************************************************************
    26. void Archives::selectmsg( const QModelIndex & idx )
    27. {
    28. accept();
    29. close();
    30. }
    To copy to clipboard, switch view to plain text mode 

    does not close the window, i don't understand

  14. #10
    Join Date
    Jan 2006
    Posts
    667
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 80 Times in 74 Posts

    Default Re: compile error that i don't understand

    in your .h file

    replace
    Qt Code:
    1. void selmsg( const QModelIndex() &);
    To copy to clipboard, switch view to plain text mode 

    by

    Qt Code:
    1. private slots:
    2. void selmsg( const QModelIndex &);
    To copy to clipboard, switch view to plain text mode 

  15. The following user says thank you to munna for this useful post:

    incapacitant (29th March 2006)

  16. #11
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Default Re: compile error that i don't understand

    yes i keep forgetting they should be declared as private slots and not just privte. thx

Similar Threads

  1. qtgui4.dll error in visual c++ 2005
    By Comptrol in forum Installation and Deployment
    Replies: 33
    Last Post: 19th June 2008, 08:18
  2. Access to PostgreSQL DB on a linux server
    By rmagro in forum Qt Programming
    Replies: 28
    Last Post: 13th March 2008, 10:02

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
  •  
Qt is a trademark of The Qt Company.