follow-up: if I need to replace the "2" with "getNumber()" like so:

Qt Code:
  1. // ...in myfile.cpp...
  2.  
  3. // QPushButton *pb[2];
  4.  
  5. QPushButton *pb[ getNumber() ];
  6.  
  7. // or
  8. // const int tempNum = getNumber();
  9. // QPushButton *pb[tempNum];
  10.  
  11. for(int a=0; a<2; a++)
  12. {
  13. pb[a] = new QPushButton;
  14. myStack->addWidget(pb[a]);
  15. }
To copy to clipboard, switch view to plain text mode 

I get an error: expected constant expression. Is there a way around this?