PDA

View Full Version : Create custom object in qt?



GeneCode
15th September 2017, 08:40
Hi all,

In objC i can create custom object like this


Car.h

@interface Car

@property (nonatomic) NSString *make;
@property (nonatomic) NSString *model;

@end

-(id)init;

Car.m

@interface Car

@implementation

-(id)init {
self = [super init];
if (self) {

}
return self;
}

@end


Question is how to make similar thing in Qt (in c++ i guess)

d_stranz
15th September 2017, 17:59
Question is how to make similar thing in Qt (in c++ i guess)

Get a C++ book or look at any one of the millions of C++ tutorials online (like this one (http://www.cplusplus.com/doc/tutorial/), this one (https://www.tutorialspoint.com/cplusplus/), or this one (https://www.youtube.com/watch?v=Rub-JsjMhWY)) and teach yourself some C++. Of course C++ supports defining and creating custom classes, as do all other object-oriented programming languages. Qt itself is C++ and defines thousands of custom objects.

GeneCode
18th September 2017, 02:41
I have basics in C++. I am well versed in ObjC and Pascal. I know the basics,
but I am looking for answers that relates more to Qt IDE in general.

What is the use of a forum if all answers to newbie questions is "go find a book"?

Qt community is not looking good right now - quite unhelpful unwilling to share and teach
newbies. I am starting a newbie tutorial blog for Qt Windows to help people like me in the future.
If you are also a newbie like me, do follow my blog and i will share what i went thru in learning Qt.
Here: https://qtnoobies.blogspot.com/ (right now i am still writing the first post ill have it posted
in a couple of days).

Thanks.... for nothing.

d_stranz
18th September 2017, 05:49
Hold on a minute. You asked


Question is how to make similar thing in Qt (in c++ i guess)

That's a basic, lesson one or two C++ question. What did you expect someone to tell you when you ask a completely open-ended fundamental question like "how do I define a class in C++"? Yes, I could have translated your Objective C code into C++, but then what? You asked a question that indicates you don't have much knowledge of basic C++, so I pointed you to resources you can use to educate yourself. Sorry if you don't think the time I spent to Google for those links, go to them, evaluate them, and then copy them into my reply wasn't helpful.

The purpose of this forum is not to teach C++ basics. It is not to teach Qt basics either. There are plenty of books, tutorials, and examples that will teach you both. This forum exists to help people, newbies and experts alike, by answering questions about and solving problems they are having with Qt. We expect you to try to solve a problem yourself first, using the tools, documentation, and examples that are out there to help. When you get stuck, we expect you to tell us what you tried, what didn't work, and if needed post the non-working code so we can help you find the problem.


I know the basics, but I am looking for answers that relates more to Qt IDE in general.

And that's what this forum is here for. To answer specific questions, not to teach fundamental things you can learn from the documentation and other resources available to you. No one here is unwilling to help, but we aren't going to spoon-feed you. We'll point you in the right direction, but you have to feed yourself.

Good luck with your blog.

GeneCode
18th September 2017, 06:38
Great lecture. Still not answering but nice paragraphs and wordings. Thanks.