0

taking into account that I have a static VALUE which is already defined in a header file (that contains other defined static values) as follow:

#defined VALUE  2

I would like to update the VALUE by passing the text taken from a QComboBox to the #defined in mainwindow.cpp, so, I am using the following line:

#defined VALUE ui->QComboBoc->currentText();

but is not working, what exactly I did wrong ?

hashDefine
  • 1,491
  • 6
  • 23
  • 33

1 Answers1

0

I suggest you learn about the C++ preprocessor, VALUE is fixed at compile time. You will have to replace it with a global static variable, or even better fix your architecture.

Community
  • 1
  • 1
cmannett85
  • 21,725
  • 8
  • 76
  • 119
  • Thanks for your reply, but I can't change the architecture as I am a member of a big team. So, my focus now is on how to update this fixed value to what I might need. – hashDefine May 16 '13 at 14:09
  • @user2390046 I don't think you understand the situation, you cannot *update* a *fixed* value - that's an oxymoron. – cmannett85 May 16 '13 at 14:14
  • Ok, I will try to change my approach to something else .. thanks anyway – hashDefine May 16 '13 at 14:29
  • 1
    I will try to remove the defined VALUE from the header file and defined it within my code – hashDefine May 16 '13 at 14:30
  • @user2390046: I wouldn't focus on the word "architecture". You're tasked with changing `VALUE`. That means it must become a _variable_. Your team will understand this. Also, you should connect the `QComboBox::currentIndexChanged` signal to a slot, and from that slot update the `VALUE` variable. – MSalters May 16 '13 at 22:37