Results 1 to 4 of 4

Thread: Unused parameters in slots

  1. #1
    Join Date
    Mar 2006
    Location
    India
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Unused parameters in slots

    I have declared a slot as follows,
    Qt Code:
    1. class Shell {
    2. Q_OBJECT
    3. public slots:
    4. void treeExpanded (const QModelIndex &index);
    5. }
    To copy to clipboard, switch view to plain text mode 

    Now, I don't have a use for the index parameter. Gcc gives a warning in this case, saying index is unused. (I try to keep my code free of warnings )

    Now, if I don't want that warning I can say,
    Qt Code:
    1. class Shell {
    2. Q_OBJECT
    3. public slots:
    4. void treeExpanded (__attribute__((unused)) const QModelIndex &index);
    5. }
    To copy to clipboard, switch view to plain text mode 

    The warning goes off but the moc generated bad code. I get a compile error for the moc_Shell.cpp
    moc_Shell.cpp: In member function `virtual int
    Shell::qt_metacall(QMetaObject::Call, int, void**)':
    moc_Shell.cpp:78: error: parse error before `*' token
    Is there any solution to this? Thanks...
    Qt 4.2 (qt-copy in KDE svn)
    KDE 4.0 (svn)
    Currently developing Anthias

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

    Default Re: Unused parameters in slots

    Yes
    Qt Code:
    1. //// *.h
    2. void treeExpanded (const QModelIndex &);
    3.  
    4. //// *.cpp
    5. void Shell::treeExpanded (const QModelIndex &)
    6. {
    7. }
    To copy to clipboard, switch view to plain text mode 
    a life without programming is like an empty bottle

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

    bmesing (22nd March 2006)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Unused parameters in slots


  5. The following user says thank you to jpn for this useful post:

    ePharaoh (22nd March 2006)

  6. #4
    Join Date
    Mar 2006
    Location
    India
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: Unused parameters in slots

    Thanks, zlatko; it worked.

    I ain't familiar with the quirks of C++.
    Qt 4.2 (qt-copy in KDE svn)
    KDE 4.0 (svn)
    Currently developing Anthias

Similar Threads

  1. Slots & Signals w/ parameters passed by reference.
    By Wazman in forum Qt Programming
    Replies: 7
    Last Post: 20th December 2008, 00:13
  2. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 10:15
  3. Signals and Slots (with structure as parameters)
    By vishwanath in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2006, 20:14
  4. Adding slots in Designer
    By jamos in forum Qt Tools
    Replies: 5
    Last Post: 18th May 2006, 23:28
  5. a Text Editor with line numbers...
    By fullmetalcoder in forum Qt Programming
    Replies: 47
    Last Post: 5th April 2006, 11:10

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.