Custom event
-
[quote author="mlong" date="1331597147"]What kind of compile errors are you getting?[/quote]
d:\my documents\qt projects\test\myclass.h(12) : warning C4002: too many actual parameters for macro 'SIGNAL'
d:\my documents\qt projects\test\myclass.h(13) : error C2958: the left parenthesis '(' found at 'd:\my documents\qt projects\test\myclass.h(12)' was not matched correctly
d:\my documents\qt projects\test\myclass.h(12) : error C2143: syntax error : missing ')' before ';'
d:\my documents\qt projects\test\myclass.h(12) : error C2661: 'QObject::connect' : no overloaded function takes 2 arguments
d:\my documents\qt projects\test\myclass.h(15) : error C2059: syntax error : 'public'
d:\my documents\qt projects\test\myclass.h(19) : error C2355: 'this' : can only be referenced inside non-static member functions
..\Test\main.cpp(7) : error C2512: 'MyClass' : no appropriate default constructor available -
Well, you're going to have to do some debugging. My code was just a guideline to the concepts that you would need to use in your program. The mechanics of it should be inconsequential.
You had asked for an example of how to lay out the structure of your program to do something. My code is to illustrate how a signal and a slot work together to do what you had asked about. Dig in a little bit, and write some code of your own, and I'm sure you'll figure it out!
Good luck! We're here to help, but I don't have the time or energy to debug the specifics right now.
-
The thing is, nothing is really explained in your example, so it's like trying to learn Greek without any English to reference. I'm a C# coder and I'm fairly good at it and can figure things out myself generally, but this is almost completely out of my comfort zone and I'm struggling somewhat.
Edit: Well you have explained a little, but most of the code is unexplained and I can't really make heads or tails of it.
-
A great easy introduction is the "Getting Started with Qt":http://qt-project.org/doc/qt-4.8/gettingstartedqt.html example here. It's a good step-by-step introduction with a lot of good references to other information (and where to get help) as it goes along.
Qt's got a lot of good examples and is extremely well documented. I know there's a learning curve of sorts, but the payoff on the other side is great.
There's a basic understanding of C++ stuff which will be required -- after all, it is a C++ tookit :)
-
I got this to work:
http://qt-project.org/wiki/How_to_Use_QPushButton
However one thing I'm a little confused about. Instead of creating a button programmatically, I want to create it with the GUI editor, so I did just that and replace all references of m_button with the object name of my created button, and then removed the creation of the old button m_button = new QPushButton, but when I run the app it crashes.