PDA

View Full Version : I'm so new, I still have that newbe smell



MagikMan
17th June 2015, 12:31
I'm using Linux Mint 17.1 64bit on a newer computer. I am doing an tabWidget app with one of the tabs being the appointments tab. I need the current date in a label. Here it is


void mainForm::on_mainTW_currentChanged(int index)
{
if(ui->mainTW->currentIndex() == 1)
{
QString mdy;
QDate::toString("MM dd yyyy") *mdy;
ui->dateLbl->text(mdy);
}
}

Can anyone help me to get this to work with explanation what I did wrong?

MM

wysota
17th June 2015, 13:48
What is this code supposed to do?

MagikMan
17th June 2015, 14:06
When the user goes to the Appointments tab a label (dateLbl) will display the current date in US format (Month, Day, Year). FYI - each tab will have an equivalent if statement to update items on their respective tabs. So simple it hurts that I can't seem to get a date-to-string statement to just display a date in text. That is why if someone could just rewrite it to do that it will break this brain freeze I seem to be in. Originally, I thought of just doing this ui->dateLbl->text(QDate::toString("MM dd yyyy)); But that didn't work so I started making changes and it just got ugly from there and I got all turned around. So when in deep **** always ask for help. Thanks for anything you might offer.

wysota
17th June 2015, 14:15
I think you should really work on your C++ before doing anything with Qt.


ui->dateLbl->setText(QDate::currentDate().toString());

MagikMan
17th June 2015, 18:59
Thank you for both bits. I will use the one and put a pin in the other. It just sank in what you were alluding to with brushing up on c++. In my retired world of patches, helping others on PLC problems I sometimes get 'stuck' in a language loop and can't seem to get out of it to do other stuff. That is what happens so if I did a bone head thing, please forgive me my transgressions, part of being as old as dirt. Thank you for your input and advice. Your small nudge broke the loop and that is all that was needed. Hope you will allow me a chance at redemption in the future. Have a better one.

d_stranz
18th June 2015, 02:04
Being old as dirt is no crime. There are plenty of us old dirt clods kicking around who can code circles around any of those young, inexperienced whippersnappers with their degrees from high-falutin' universities who learned Python and HTML and think they're wizards. Age, treachery, and 40+ years of coding matter.

Qt is a steep learning curve. I've been at it since 2008 or so, and there are still vast parts of it I don't know and nuances to the parts I do know that I don't use much. This forum and some of the posters with > 2^n posts (n being large) have helped greatly, even if the posts I read don't have immediate relevance.