Results 1 to 10 of 10

Thread: slot no work in another class

  1. #1
    Join Date
    Jan 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default slot no work in another class

    I haven't errors but when i build programm, debug write QObject::connect no such slots Myclass ::MyVoid().
    what is it?
    Thank's for answers!

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: slot no work in another class

    Show us some code

    My guess is that you either made some mistake when called connect.
    or is void MyVoid() declared as public slots: in the definition of Myclass?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: slot no work in another class

    Also make sure your class has the Q_OBJECT macro and qmake is called after adding it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jan 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: slot no work in another class

    thanks for answers but I declared MyVoid as public slots and my class has the Q_Object macro and sorry that i don't show code because it on other computer and If you need I show code, please wait a moment..


    Added after 13 minutes:


    Qt Code:
    1. #ifndef __MENUONLEFRLIST_H__
    2. #define __MENUONLEFRLIST_H__
    3. #include <QAction>
    4. #include <QMenu>
    5. #include <QDialog>
    6. #include "ui_CatalogView.h"
    7. #include "CatalogViewImpl.h"
    8.  
    9. class Menu : public QDialog, public Ui::CatalogView
    10. {
    11. Q_OBJECT
    12. public:
    13. void createMenu(const QPoint &p);
    14. private:
    15. void createActions();
    16.  
    17. QMenu *menu;
    18.  
    19. QAction *addDirectory;
    20. QAction *Rename;
    21. QAction *Delete;
    22.  
    23. };
    24.  
    25. #endif // __MENUONLEFRLIST_H__
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "menuOnLeftList.h"
    2.  
    3. void Menu::createActions(){
    4. addDirectory = new QAction("Add directory", this);
    5. connect (addDirectory, SIGNAL(triggered()), this, SLOT(addBranch()));
    6. Rename = new QAction("Rename", this);
    7. //connect();
    8. Delete = new QAction("Delete", this);
    9. //connect();
    10.  
    11. }
    12.  
    13. void Menu::createMenu(const QPoint &pos){
    14.  
    15. createActions();
    16.  
    17. menu = new QMenu();
    18. menu->addAction(addDirectory);
    19. menu->addAction(Rename);
    20. menu->addAction(Delete);
    21. menu->exec(pos);
    22.  
    23. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #ifndef __CATALOGVIEW_H__
    2. #define __CATALOGVIEW_H__
    3. #include <QDialog>
    4. #include <QTreeView>
    5. #include <QMouseEvent>
    6. #include <QObject>
    7. #include <QPoint>
    8. #include "menuOnLeftList.h"
    9. #include "ui_CatalogView.h"
    10.  
    11. class CatalogViewImpl : public QDialog, public Ui::CatalogView
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. CatalogViewImpl(QWidget * parent = 0);
    17. private slots:
    18. void newFolder();
    19. void addBranch();
    20. void searchT();
    21. void updateCatalog();
    22. void searchClicked();
    23. void newClass();
    24. //void showMenu(const QPoint &p);
    25. };
    26.  
    27. #endif // __CATALOGVIEW_H__
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include <QMouseEvent>
    2. #include "CatalogViewImpl.h"
    3. #include "ClickHandler.h"
    4. #include <QAbstractItemView>
    5.  
    6. int i;
    7. QPoint *point;
    8. ClickHandler *listEvHandler;
    9. CatalogViewImpl :: CatalogViewImpl(QWidget * main):QDialog(main)
    10. {
    11. setupUi(this);
    12.  
    13. model = new QStandardItemModel();
    14. treeView->setHeaderHidden(true);
    15. treeView->setModel(model);
    16. listEvHandler = new ClickHandler();
    17. treeView->installEventFilter(listEvHandler);
    18.  
    19. connect (listEvHandler, SIGNAL(send_rightButtonClicked(const QPoint&)), this, SLOT(createMenu(const QPoint &)));
    20. ...
    To copy to clipboard, switch view to plain text mode 

    QObject::connect no such slots CatalogViewImpl::createMenu();
    Last edited by Aronax; 10th January 2011 at 14:10. Reason: missing [code] tags

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: slot no work in another class

    So what is the exact message you get? With proper class names and all...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jan 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: slot no work in another class

    when i do it in CatalogViewImpl class without created new class all works fine!
    Exact message: QObject::connect: No such slot CatalogViewImpl::createMenu(const QPoint &);
    QObject::connect: (receiver name: 'CatalogViewImpl')

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: slot no work in another class

    What new class? You mean "Menu"? It has nothing to do with your original class so your original class doesn't contain slots defined in the Menu class.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    Aronax (11th January 2011)

  9. #8
    Join Date
    Aug 2009
    Location
    Greece, Chania
    Posts
    63
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: slot no work in another class

    createMenu(const QPoint &) belongs to class Menu and not to class CatalogViewImpl.
    And you do this in CatalogViewImpl constructor:

    connect (listEvHandler, SIGNAL(send_rightButtonClicked(const QPoint&)), this, SLOT(createMenu(const QPoint &)));
    Misha R.evolution - High level Debugging IDE

    Programming is about 2 basic principles: KISS and RTFM!!!

  10. The following user says thank you to Archimedes for this useful post:

    Aronax (11th January 2011)

  11. #9
    Join Date
    Jan 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: slot no work in another class

    As new class I keep in mind Menu class

    Yes, but send_right ButtonClicked is separate class too but it's work..

  12. #10
    Join Date
    Jan 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: slot no work in another class

    Thanks for answers!! I understood my mistake!

Similar Threads

  1. Replies: 5
    Last Post: 14th September 2010, 21:13
  2. Slot doesn't seem to work
    By waynew in forum Newbie
    Replies: 3
    Last Post: 10th November 2009, 09:54
  3. minimize slot does not work in linux.Is it a Bug in Qt?
    By anupamgee in forum Qt Programming
    Replies: 4
    Last Post: 4th June 2009, 08:18
  4. Replies: 12
    Last Post: 18th September 2008, 15:04
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36

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.