Please don't be so hostile. I just want to help you.
And yes, if you want something as specific as you want, and it doesn't exist, the only thing you can do is create it yourself.
Basically, that's what you already got above.
Your question does not belong in the newbie or even advanced section. You question belongs in a "super geeky nerd" section.
Look at it from the other side.
What I think you have done is made some poor choices along the line.
Can you explain exactly what you want to do in clear and plain text. Don't use the following words: preprocessor, templates, moc
And be verbose.
This is obviously false.
I think you might have just beat the other poster in this thread for most ridiculous response ever, though it is pretty hard to compete with using ifdef to autogenerate classes. Not only is it completely redundant to say, "If it doesn't exist then make it," it is also quite possibly the very wrong thing to do, especially if the cost to make it is higher than worth. Several other options come to mind: live without it, don't use Qt, etc... All of which are quite redundant and beside the point of the real question though and amount to no more than simple efforts to be obnoxious.And yes, if you want something as specific as you want, and it doesn't exist, the only thing you can do is create it yourself.
BULL. The question is simple: how do you use the preprocessor or templates to generate Qt objects.Your question does not belong in the newbie or even advanced section. You question belongs in a "super geeky nerd" section.
The answer is also quite simple and still I'm the only one in this entire thread that even mentioned it: you can't. The rest of your guys' nonsense is just that.
Which is simply an amazing presentation of mind-reading abilities.What I think you have done is made some poor choices along the line.
The question is, and has always been, quite clear in my first post and I answered it myself (in spite of attempts to send me down blind alleys) quite a long time ago; even to the point of including exactly the problem I'm trying to solve.Can you explain exactly what you want to do in clear and plain text. Don't use the following words: preprocessor, templates, moc
And be verbose.
What I mean with helping you is to get to the point to have something that you want.
You're fixed on the preprocessor. Maybe there's another way to do what you want.
But to know this, I need to know exactly what you want, and that's still not clear for me.
By the way, there's a Qt mailing list where you can ask the Qt developers directly for support.
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
I can't decipher what it is you're trying to accomplish, but the C/C++ preprocessor is almost trivially simple; you can learn all there is to know about it in a couple of hours. If you can't figure out how to accomplish something using it, you either have to A) devote a small amount of time to learning how it works, or B) recognize that the preprocessor is almost certainly the wrong tool, and look for another solution.
For starters, perhaps you should also devote some time to A) being polite, and B) providing a reasonably detailed explanation of what the problem is you're trying to solve. Without more information, it's really impossible to suggest any reasonable solution other than to mention that there are many potential tools available for generating code - lex, yacc, perl, python and dozens of others, not to mention C++ and maybe - just maybe - the preprocessor.
The preprocessor is absolutely the right tool for the job and is fully capable of doing exactly what I want. The problem stems from having to use the MOC and its inability to play well with the preprocessor and with templates.
I think the real problem here is that "Newbie" on this forum isn't a place for new Qt users to get help from expert users, but where those answering are also newbies. Even the moderator seems particularly so. Nothing wrong with being a newbie but it is particularly frustrating to ask for help expecting knowledgeable people and running into a bunch of yahoo's claiming to be experts but spout nonsense. In other words, I come here as a complete newb to Qt and have found that the "experts" know less than I do at apparently every level. My bad for coming to the wrong place I suppose, but in my defense it is one of the support links on the Qt site proper.
That said, I'm pretty tired of people "answering" my question just to claim I'm being a) impolite or b) not specific enough. The question is quite clear and has actually been answered already. Anyone else doing so is just going to end up on my ignore list, and if you're here to actually get help....I am an expert; I just happen to be new to Qt. I also don't waste your time with my own ignorance. If you actually have something pertinent to my question that hasn't been brought up then I'm all for hearing it, but I'm tired of people just posting to flame.
When I learned to be an engineer, I was taught that impossible problems do not exist. One tool to solve an impossible problem is to rethink what you want to do. There are always multiple paths to achieve what you want.
So, if you explain in plain english, without refering to a specific technique, what you want to do, someone might give you an better solution. Even if you are a pro, please keep your feet on the ground and accept that even the village idiot might give you inspiration.
After saying you doubt that would work with moc you then suggested
Qt Code:
#ifdef MAKE_OBJECT ... #endifTo copy to clipboard, switch view to plain text mode
This is a purposefully unhelpful response from anyone who knows anything about C++. My actual assumption was that you were an idiot that didn't know anything about C++ or Qt rather than the apparently actual case...you knew exactly what I was trying to do and even had information that might help me that you withheld.
Only now, after weeks of bullshit, you post something mildly interesting in an apparent quest to prove your knowledge rather than being helpful, which you could have done a LONG time ago if you had really wanted. I'd ask for expansion on the idea you finally decided to mention but to tell the truth I'm so sick of your crap that I would rather just investigate the possibility myself. On the other hand, at this point I do have to take into account the very distinct possibility that you've just found a different way to send me off on a wild goose chase to waste even more of my time.
Of course, I'm not trying to avoid anything but a bunch of extra, pointless coding of small utility classes that should be easy to generate automatically. This is the first time you've even said anything that wasn't completely absurd AND redundant.
Added after 4 minutes:
Copied from my original post:
Namely I want to make a QObject that has a slot with some arbitrary signature that translates a Qt signal into a boost signal (which I can use bind with).
Last edited by nroberts; 27th December 2010 at 22:07.
That's not true. That was a direct answer to a snippet you posted, namely:
This wouldn't work because at the time when MAKE_OBJECT is expanded by cpp it is already too late to generate a meta-object for the class.Qt Code:
#define MAKE_OBJECT \ { \ Q_OBJECT \ public slots: \ void do_nothing {} \ }; MAKE_OBJECTTo copy to clipboard, switch view to plain text mode
Using this instead:
and defining MAKE_OBJECT prior to calling qmake (i.e. DEFINES += MAKE_OBJECT) would probably work because there is a good chance that the meta-object would be generated (as Q_OBJECT macro is present in class definition) and then cpp would expand the macro and compile the proper code.Qt Code:
#ifdef MAKE_OBJECT { \ Q_OBJECT \ public slots: \ void do_nothing {} \ }; #endifTo copy to clipboard, switch view to plain text mode
This is probably not what you want as what I understand now (at least I think so), you want to actually want the macro to have variables for signal/slot signatures. This wasn't evident at the time of your writing so you can only blame yourself for providing a code snippet unrelated to what you actually want to do instead of judging my C++ skills. They are yet to fail me.
That's a good example that you should think twice before making such assumptions.My actual assumption was that you were an idiot that didn't know anything about C++ or Qt rather than the apparently actual case...
I did not, look at my first post in the thread. I'm still not sure I do.you knew exactly what I was trying to do
That's your personal opinion and it's false. I sometimes do withhold information because of my own reasons (mainly educational to push someone in the right direction and let him find the solution himself instead of providing off-the-shelf code for them) but not in this case.and even had information that might help me that you withheld.
Sorry to be blunt but I think others would also agree that if someone was trolling, it was not me. And you are really balancing on the edge with your posts. We're patient here but our patience has its limits and order needs to be kept so please constrain yourself a bit when it comes to choosing words you use.Only now, after weeks of bullshit, you post something mildly interesting in an apparent quest to prove your knowledge rather than being helpful
Without this crap you would have nothing to investigate. Bear that in mind.I'd ask for expansion on the idea you finally decided to mention but to tell the truth I'm so sick of your crap that I would rather just investigate the possibility myself.
I suggest you stop wasting your time and switch jobs, hobbies or whatever makes you be a software developer. Become an astronaut or a shoe salesman, I don't really care. If you keep being rude the job won't really matter -- you'll still just be a rude person.On the other hand, at this point I do have to take into account the very distinct possibility that you've just found a different way to send me off on a wild goose chase to waste even more of my time.
Thank you. We're still waiting for your first time to say "thank you" and stop being rude.Of course, I'm not trying to avoid anything but a bunch of extra, pointless coding of small utility classes that should be easy to generate automatically. This is the first time you've even said anything that wasn't completely absurd AND redundant.
To really answer "properly" the problem you described in a so obscured way: you need to handle the whole signal activation routine yourself. Infrastructure for it is usually provided by the meta-object generated by moc but all the code really required is already there (in Qt) without it, there is just no infrastructure to use it. This is something you have to provide yourself and to do that you need to dig deeply in Qt's code since there is a couple of undocumented methods that you need to use. Also read this article, it describes a very simplified mechanism (based on Qt3) for handling custom signals (which is more or less what you want to do): http://doc.qt.nokia.com/qq/qq16-dynamicqobject.html. And forget the C preprocessor, I don't have the slightest idea how you wanted to use it to solve your problem. I would rather go in the direction of using C++ templates rather than cpp (although that wouldn't work here as well as templates are expanded by the compiler so they can't contain Q_OBJECT macros).
Wow, just wow. Someone who's arrogance sets a new high on this forum and still wysota tries his best to help only to shot down in flames at every turn.
Maybe next time you post a question we should just completely ignore you. At least then you can't rip our heads off for trying to understand and answer your question.
In my opinion, there was nothing wrong with the answers given. After all, the first answer given by Wysota did exactly what you asked - "This doesn't work", "No, but this will", and the other answers were also very reasonable in my eyes (but of course, you will argue that fact)
You also seems to be forgetting that this forum is provided for free, as are the people who are answering your posts. If you wish for a more professional, tried and tested approach to your exact requirement, maybe you try out the paid support instead of the free volunteer support.
I just received an infraction for using bad words in this post. Would someone be so kind as to explain which of those words was inappropriate for civilized conversation?
You asked for thanks, I gave it even though I thought it undeserved.
Added after 5 minutes:
If you wish to ignore my questions that would be fine with me and in many cases that may be more helpful. This isn't the only thread in which wysota has responded to my requests for help in unhelpful manners. For example, I asked another question regarding receiving events when the user is finished editing in the property browser library. Someone without the moderator/expert tag helped me by explaining that it wasn't possible given the API and showed some sections of source that might be helpful. Wysota jumped in with, "You're doing it all wrong!!!" and then proceeded to tell us to connect to signals that did what I quite specifically said I had already tried and did not want in the OP.
I've actually asked Wysota to ignore my questions. He/she doesn't want to apparently even though it's quite clear they are unwilling or unable to actually help me.
Last edited by nroberts; 27th December 2010 at 23:47.
Bookmarks