Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Problem with slots
hi to every one
i have a mainwindow class that inherited from qmainwindow
and i have another class named class2 that inherited from qdialog;
and in my mainwindow class i redefine my class2 with this code
class2 en = new class2(this);
on class2 i have a qpushbutton named button1;
i wrote this code in my class2 constructor to use slot
and i add adddatabase() function to my private slots
but when i click on button1 it does'nt run adddatabase() function
what is my problem?
[EDIT: code formatting, please wrap in @-tags, Volker]
goetz last edited by
remove "this->" from the SLOT():
connect(ui.button1, SIGNAL(clicked()), this, SLOT(adddatabase()));
to late ;)
<how can I delete posts?>
goetz last edited by
[quote author="mrtc3" date="1312892166"]to late ;)
<how can I delete posts?>[/quote]
I don't know if that's possible for non-moderators.
Anyways, it does not hurt to have doubled answers. I consider it an advantage and a proof of an active community :-)
i remove this but it does'nt change anything and my aadddatabase() function does'nt run
[quote author="Volker" date="1312892535"]I consider it an advantage and a proof of an active community :-)[/quote]
So answers are welcome, and I can train my Qt skills ;)
kitten: adddatabase() must be declared as a slot in your header file.
and if its derived from QDialog the Q_OBJECT macro should be set.
when i add Q_Object macro on my project it get me this eror:
1>------ Build started: Project: finger, Configuration: Debug Win32 ------
1>moc: Too many input files specified
1>Usage: moc [options] <header-file>
1> -o<file> write output to file rather than stdout
1> -I<dir> add dir to the include path for header files
1> -E preprocess only; do not generate meta object code
1> -D<macro>[=<def>] define macro, with optional definition
1> -U<macro> undefine macro
1> -i do not generate an #include statement
1> -p<path> path prefix for included file
1> -f[<file>] force #include, optional file name
1> -nw do not display warnings
1> @<file> read additional options from file
1> -v display version of moc
1>Project : error PRJ0019: A tool returned an error code from "Moc'ing enroll.h..."
1>Build log was saved at "file://c:\Users\sazgar\Documents\Visual Studio 2008\Projects\finger\finger\Debug\BuildLog.htm"
1>finger - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I guess "this":http://developer.qt.nokia.com/forums/viewthread/1951I is wide spread: moc it manually again "moc.exe enroll.h -o moc_enroll.cxx" and add that *.cxx to your project (Add --> Existing Item..). This worked when I had this problem.