Hi everyone, I'm kinda introducing myself to the forum and going to ask a question too, I feel I may be in and out of here quite a bit, I am determined to crack this! XD
Let me just say, I am hopefully in here to chat (about code) as much as I am to ask specific questions, So there will be rambling... You are warned... lol
For the past 3 days I have been studying this video...
http://www.youtube.com/watch?v=-WwGMNGRHdw
It seems like a great resource for anyone else that is trying to learn C++ so thought I would pop it in there, if that is okay, if not please remove it at will.
I am kinda getting a small inkling as to how certain parts work, but the project I am dealing with is super complex (to a mere newb like me).
You could say, well do something easier first...
Sure I could and I have tried some simple projects and was delighted when they worked :)
But I also want to dive right in the deep end and get stuck in there! lol
So... this brings me to the question...
I have a program that is already in existence, and I want to modify it (I do this a lot with website templates etc)
More specifically I want to take a piece of data that is being displayed in a tooltip (I am using qt creator, the prog was written with it) and display it some where else. The tooltip in question is in itself populated by live data, not just something plopped on a qlabel in qt-designer, just to be clear.
So first attempt I thought aha, I will copy everything and paste it in to the new page where I want it and bingo! Nope... XD Turns out this info I want trails back about 8 pages lmao... By doing this (tracing back all the pages and copying and altering names slightly) I did manage to get some data to show in the place I wanted it, but it seemed like a bit of a crazy number, that would change only when you reloaded the application and sometimes it wouldn't change at all. When I say a crazy number, I mean a number I don't recognize to represent anything, certainly not what I wanted.
Then, by watching the video above I learned about classes (YAY we got there! the subject lol). I saw how I could call a class from another, this seemed a better approach than copying all the code XD. I learned also about class permissions, and I got to the point where the compiler tells me that the method I am trying to get to is in private! YAY! That was awesome for me as it meant that it was at least trying to talk to the right page and code section.
I am kinda used to doing things like this with css and javascript etc when mucking about with websites.
The problem I have now is how to access these private areas, I have added a "freind class" to the target page... but I am a little confused with how to use it.
It would also seem that the private areas I want to access use pointers (something I have not fully read up/watched about yet.
This is from the target header file.
1 2 3 4 5 6 7 8
|
Q_OBJECT
public:
explicit BitcoinGUI(QWidget *parent = 0);
~BitcoinGUI();
friend class OverviewPage;
private:
QLabel *labelStakingIcon;
|
This is from the .cpp that wants to be able to use these private methods
1 2 3 4 5 6
|
int updateStakingIcon()
{
return BitcoinGUI::labelStakingIcon();
}
|
Now label staking icon is a picture obviously so thought it would be a nice easy target in learning how to use these methods from within another class...
I don't know what I would do once that gets past the compiler, but cross that road when I get to it.
For those that read all my drivel, well done. :)
Please don't berate me for my long drawn out comment, I like to give a bit of background and besides I did warn you in the first few sentences. lol