c++ - How to use qpixmap on another class? -


i'm trying create qlabel icon qpixmap. function:

void myclass::myfunction() {     qpixmap on_icon(":/path");      ui.label_1.setpixmap(on_icon); } 

my problem can use on_icon in myfunction. how can use on different functions :

void myclass::myotherfunction() {     ui.label_2.setpixmap(on_icon); } 

as thuga commented. 1 possibility make qpixmap member variable of myclass. way pixmap label wherever need qlabel::pixmap() method.

void myclass::myfunction() {     qpixmap on_icon(":/path");     ui->label_1->setpixmap(on_icon); }  void myclass::myotherfunction() {      qpixmap *on_icon = ui->label_1->pixmap();      ui->label_2->setpixmap(*on_icon); } 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -