Alias of a variable in C++/Qt? -


is there way create alias of ui variable in qt ?

this var

ui->combobox->currentindex()

becoming example

index

so whenever in code call index value of ui->combobox->currentindex() if changed during 2 calls.

i tried same value, 1 during initialization.

int *index = 0;
index = (int *)ui->combobox->currentindex() // equals -1 time;
(int)index; //always return -1 if ui->combobox->currentindex() returns 0;

the goal reduce length of long statement.
:)

possibly best way do add inline function returns current index:

inline int mainwindow::myindex() const {   return ui->combobox->currentindex(); } 

then can call myindex() whenever need value.

or assign local variable before statement using in:

int const index = ui->combobox->currentindex(); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -