你好!
在嵌入式开发中,qt中想新建多个控件,如何共用相同的背景图片,减少内存?
比如:
QWidget *smart_main_w1;
QWidget *smart_main_w2;
QWidget *smart_main_w3;
smart_main_w1 = new QWidget(this->s_parent);
smart_main_w1->move(0*,0);
smart_main_w1->resize(500,500);
smart_main_w1->setAutoFillBackground(true);
smart_main_w1->setStyleSheet("background-image:url(img/main_half.png)");
smart_main_w1->show();
smart_main_w2 = new QWidget(this->s_parent);
smart_main_w2->move(0*,500);
smart_main_w2->resize(500,500);
smart_main_w2->setAutoFillBackground(true);
smart_main_w2->setStyleSheet("background-image:url(img/main_half.png)");
smart_main_w2->show();
smart_main_w3 = new QWidget(this->s_parent);
smart_main_w3->move(0*,1000);
smart_main_w3->resize(500,500);
smart_main_w3->setAutoFillBackground(true);
smart_main_w3->setStyleSheet("background-image:url(img/main_half.png)");
smart_main_w3->show();
问1:如果像上面红色语句,3个控件smart_main_w1,smart_main_w2,smart_main_w3,都是相同的背景颜色,嵌入式开发中占用内存就很大,有什么样的方法可以实现这3个控件公用这张图片,比如这3个控件都指向同一张图片的指针?谢谢!!!