Re: Application crashes at launch-time
This is access to GUI element, as you said. My code (subclassing) looks almost the same, and it doesn't work, because I have wrong GUI element access.
p.s.
I changed contents of my main.cpp file (it was wrong code in it) and it works.
edit. I mean that it doesn't crash, window is displayed but with no functionality. If I added ui. prefix in refering to GUI element would it be ok?
Re: Application crashes at launch-time
yes - but then you will stumble on the next error, and you wont understand why.
This is no way to learn C++.
Do it properly from the start.
Re: Application crashes at launch-time
Sure, I'll read classes chapter in C++ Symphony (Symfonia C++)
Re: Application crashes at launch-time
But there still is a problem. I added .ui prefix in every reference to gui element e.g. ui.convertButton->hide(); instead of convertButton->hide(); But it still doesn't have functionality. Did I miss something?
Re: Application crashes at launch-time
Quote:
But there still is a problem.
Which is exactlxy what I said in my last post:
Quote:
yes - but then you will stumble on the next error, and you wont understand why.
This is no way to learn C++.
Do it properly from the start.
Re: Application crashes at launch-time
;)Of course, you're right:)
Re: Application crashes at launch-time
Now I understand why do we have to use .ui prefix. Because in main cpp before creating dialog we define Ui::Dialog ui; where ui is a variable of the class in which is setupUi so that we have to call ui prefix to refer content of setupUi class. Is that right?
Re: Application crashes at launch-time
Well, yes and no.
Yes - but its not a "prefix".
Its an object, which has elements, and that is the way you reference elements of objects in C++.
But as you see, once you started reading a bit, things get much clearer.
Continue so.:cool:
You don't have to post here each time you learn a new C++ concept, we know them already ;)
You are welcome to ask specific question in the General Programming sections any time though.
Re: Application crashes at launch-time
I read classes chapter of my book and I think that there's something wrong with calling just e.g. hide():
Code:
ui.convertButton->hide();
But I don't know what. ;)
edit:
or maybe no. In docs it was something like this:
Code:
ui.colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
Could you tell me, what's wrong? I understand classes, but don't know why application doesn't have any functionality (the only working thing is exit button which closes dialog. But connection was made in designer)
Re: Application crashes at launch-time
provided that 'ui' is a valid member variable, that has accessible member pointer 'convertButton' that has an accessible member function 'hide()' - your code is correct.
With correct syntax your code will compile.
But correct systax is not enough for correct functionality.
Why your program does not function the way you expect it is another question, which has to do with your programs design.
But that is another story, which I suggest you leave at the moment.
Concentrate on C++ first.
Do some simple example programs and learn the concept.
Just readin one chapter in the book, does not make you REALLY know object oriented programming.
Re: Application crashes at launch-time
Do you really think that all I know about C++ is how to access class member?? I know C++ quite well, but I didn't use classes in my problem, that's the reason why I didn't understand "accessing GUI elements", and it doesn't mean that I don't know C++. What is wrong in my code? I really don't know... Regards
Re: Application crashes at launch-time
Quote:
Originally Posted by
Salazaar
I know C++ quite well, but I didn't use classes in my problem,
If you didn't use classes, what did you use then? Is the code of any of your programs available for download? I'd like to take a look at it.
Re: Application crashes at launch-time
I used combination of functions. No, the code isn't availible because as I said once my console programs are histroy. I'll ask you once more, why my application doesn't have functionality? Regards
Re: Application crashes at launch-time
Quote:
Originally Posted by
Salazaar
I used combination of functions.
So where was C++ in that? Maybe it was C then?
Quote:
No, the code isn't availible because as I said once my console programs are histroy.
That's a pitty... Were they some school projects or something you did for fun?
Quote:
I'll ask you once more, why my application doesn't have functionality?
Define "functionality". Does it contain widgets? Are they connected using signals and slots? Give us more details (be warned though, we'll still be assuming you know what you're doing regarding C++ syntax and semantics).
Re: Application crashes at launch-time
You are being very forceful and expecting the good people on here just to fix your problem.
You have been told to read more on C++ and I believe you should do. The best way to learn and fix your problems is by sitting down and trying to do it yourself first.
I'm sorry to sound hard, but having read lots of your posts, it seems you are just expecting to post your code on here and expect it to be fixed for you.
Re: Application crashes at launch-time
Quote:
I'll ask you once more, why my application doesn't have functionality?
We don't even know what functionality you are talking about.
Do you know how to use signals and slots?
1 Attachment(s)
Re: Application crashes at launch-time
Quote:
Originally Posted by
high_flyer
We don't even know what functionality you are talking about.
Objects on which I was doing:
Code:
ui.element->hide();
doesn't work, nextStepButton does nothing and so on. Maybe It'll b e better if you can see my code. I'll attach dialog.cpp
Quote:
Originally Posted by
high_flyer
Do you know how to use signals and slots?
Your kidding me?;) Of course, I know.
edit:
The problem isn't that I don't know how to connect signals to slots, I have functions which do something, connected to something and all should work, but it doesn't. Look at my file
Re: Application crashes at launch-time
well, settingUp() is a bunch of if() clauses.
Probably none of them gets to be true, so nothing happens.
Put a debug statement in and see if its being printed:
Code:
bool Dialog::settingUp()
{
qDebug()<<"Dialog::settingUp()";
//the rest of your code.
}
In addition make sure you get no signal/slot warnings when you execute the application.
Re: Application crashes at launch-time
Quote:
Originally Posted by
high_flyer
well, settingUp() is a bunch of if() clauses.
Probably none of them gets to be true, so nothing happens.
None?? If I, let's say' check checkbox in one group, and second in second grop and if nextStep Button is clicked one if() clause sure returns true and all instructions in if() should be done. But even if is a problem (which I think it isn't a problem) some widgets should be hidden, and we can type any value (even string) to lineEdit, although I have a validator.
Quote:
Originally Posted by
high_flyer
In addition make sure you get no signal/slot warnings when you execute the application.
No, I don't have any signal/slots warning when executing application.
Re: Application crashes at launch-time
did you try the code I gave you in the last post?