Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: Problems with Q_OBJECT macro

  1. #1
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Problems with Q_OBJECT macro

    Hi

    I am having a bizarre problem with Q_OBJECT macro, if I include the maco in my class declaration the program does not run with the error

    "You can't do that without a process to debug"

    Qt Code:
    1. #include <qwt_plot.h>
    2.  
    3. class QSpinBox;
    4. class QDialog;
    5. class Fitting;
    6.  
    7. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    8. class FittingPlot : public QwtPlot
    9. {
    10. Q_OBJECT //the program runs if this is if commented out
    11.  
    12. public:
    13. FittingPlot(QWidget *parent = NULL);
    14.  
    15. public slots:
    16. void upd();
    17.  
    18. private:
    19. QSpinBox* aSpinBox;
    20. QSpinBox* bSpinBox;
    21. QVBoxLayout* layout;
    22. QDialog* diag;
    23.  
    24. Fitting* tfit;
    25. int mtest;
    26. };
    To copy to clipboard, switch view to plain text mode 

    This the implementation

    Qt Code:
    1. #include <qwt_plot.h>
    2. #include <QtGui>
    3.  
    4. #include "FittingPlot.h"
    5. #include "Fitting.h"
    6.  
    7. FittingPlot::FittingPlot(QWidget *parent)
    8. :QwtPlot(parent),mtest(0)
    9.  
    10. {
    11. aSpinBox = new QSpinBox;
    12. bSpinBox = new QSpinBox;
    13. layout = new QVBoxLayout();
    14. layout->addWidget(aSpinBox);
    15. layout->addWidget(bSpinBox);
    16. diag=new QDialog(this);
    17. diag->setLayout(layout);
    18. diag->show();
    19.  
    20. tfit=new Fitting();
    21.  
    22. QObject::connect(aSpinBox,SIGNAL(valueChanged(int)),tfit, SLOT(setTargetThreshold(int)) );
    23. QObject::connect(aSpinBox,SIGNAL(valueChanged(int)),tfit, SLOT(run()) );
    24. QObject::connect(aSpinBox,SIGNAL(valueChanged(int)),this, SLOT(upd()) );
    25. }
    26.  
    27. void
    28. FittingPlot::upd()
    29. {
    30. mtest++;
    31. }
    To copy to clipboard, switch view to plain text mode 

    When the code does run (with Q_OBJECT commnented out, the slot upd does not get called with warnin message

    "warning: Object::connect: No such slot QwtPlot::upd()

    The other two slots work in the Fitting Class work OK

    Does anyone have any ideas why this is happening?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems with Q_OBJECT macro

    try to remove #include <qwt_plot.h> from cpp, but I think this not a problem.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    Thanks for the advice, but I still does not work, I still get the error

    "You can't do that without a process to debug"

    I am using eclipse on winXp.

    I also get the same problem with QDevelop but different error

    Program received signal SIGSEGV, Segmentation fault.
    Program exited with code 030000000005.

    Anyone any ideas?

    Thanks

  4. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with Q_OBJECT macro

    could the crash be because u have three different slots connected to the same signal and the order in which they r executed might not be appropriate and is causing the crash?

  5. #5
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    Thanks but no that isn't the problem, the slot functions are presently dummy functions and the call order doesn't matter.

    I have rejigged the code, rather than inherit from QwtPlot, I inherit from QWidget, it runs Ok (i.e displays the Widget). The problem is that I want to inherit from QwtPlot

    Thanks

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems with Q_OBJECT macro

    maybe you should better as this question in Qwt subforum and Uwe probably helps you
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    Thanks Spirit, I will

  8. #8
    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: Problems with Q_OBJECT macro

    Did you remember to rerun qmake after adding the macro? For me it looks like the program fails to rebuild with the macro thus the message you get. Qwt has nothing to do with 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.


  9. #9
    Join Date
    Sep 2008
    Posts
    14
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Problems with Q_OBJECT macro

    i agree with wysota. please make a clean metaobject file which qmake already does,
    start with a new pro file, a new environment .
    moc -o x_moc x.h

    add the moc file in the main cpp file
    #include "x_moc"

    kindly read Q_OBJECT problems due to moc..

    it may not exactly solve the problem but good to give a try.

  10. #10
    Join Date
    Jan 2009
    Posts
    54
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    Are you sure it is correct the eclipse configuration? becuase maybe there is a Eclipse problem to find the debugger. Specify the gdb ruth in debug configuration.

    And have you include the QT and the compiler (MinGw) in the CLASS PATH?

    Cheers

  11. #11
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    Hi

    I dont think it is an eclipe/qt problem as I have other qt/qwt projects that work just fine

    If my class inherits from QWidget, I dont have a problem, only when inheriting from QwtPlot

    Thanks
    Last edited by dbrmik; 23rd February 2009 at 09:33. Reason: updated contents

  12. #12
    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: Problems with Q_OBJECT macro

    Please provide a minimal compilable example reproducing the problem.
    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.


  13. #13
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    I have attached the project as a zip file, hope that OK
    Attached Files Attached Files

  14. #14
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems with Q_OBJECT macro

    try this
    Qt Code:
    1. class FittingPlot: public QwtPlot
    2. {
    3. Q_OBJECT
    4. public:
    5. FittingPlot(QWidget *parent = 0) ;
    6. ....
    7. };
    8.  
    9. FittingPlot::FittingPlot(QWidget *parent)
    10. : QwtPlot(parent)
    11. {
    12. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  15. #15
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    Thanks but I still get the same error

    "You can't do that without a process to debug."

    Grrr

  16. #16
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems with Q_OBJECT macro

    did you rebuild all project? did you remove old obj-files? did you run qmake after cleaning project dir?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  17. #17
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    Yes, after cleaning the project I checked the files were deleted Ok. I think Eclipse handles the Qmake process, however I did it manually from the command line. But I still get the same error.


    Thanks

  18. #18
    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: Problems with Q_OBJECT macro

    Quote Originally Posted by dbrmik View Post
    I have attached the project as a zip file, hope that OK
    It works for me without a problem. A simple qmake && make compiled the project just fine. I have Qwt 5.1.1 installed with Qt 4.4.3.
    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.


  19. #19
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with Q_OBJECT macro

    Thanks wysota, that's good to know. Still not working here, I also have Qwt 5.1.1 installed with Qt 4.4.3 running on xp using eclipse. I get the same problem usng QDevelop. As I metioned earlier I have other projects using the qwt library, however I am not subclassing QwtPlot, I'm adding it as a widget to a MainWindow with no problems, I suppose I'll have to live with it for now

    Thanks once again for your time

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

    Default Re: Problems with Q_OBJECT macro

    What happens if in FittinPlot.cpp you substitute '#include "FittingPlot.h' for '#include "FittinPlot.moc"'?

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.