Sets the Qlabel fill picture and sets the size of a picture to the width and height of the Qlabel border.
Ui->dangqian_tianqi_img_label->width ()//is the width of the Qlabel
Ui->dangqian_tianqi_img_label->height ()//high for Qlabel
Qpixmap Tianqi_pixmap (":/img/ico/qing.png");
Qdebug () << tianqi_pixmap.width () << "/" << tianqi_pixmap.height ();
Tianqi_pixmap = tianqi_pixmap.scaled (Ui->dangqian_tianqi_img_label->width (), Ui->dangqian_tianqi_img_ Label->height (),
qt::ignoreaspectratio, qt::smoothtransformation)//Set picture size and label long width consistent
ui-> Dangqian_tianqi_img_label->setpixmap (TIANQI_PIXMAP);
Ui->dangqian_tianqi_img_label->show ();
void Login::set_top_img (bool issandom, int index_img) {//427 185 int set_index_img = 1;
if (Issandom = = true)//randomly displays topimg {qtime time_sand;
time_sand= qtime::currenttime ()//Get the current time Qsrand (Time_sand.msec () +time_sand.second () *1000); Index_img = Qrand ()%5//Select random number in 0-4 set_index_img = Qrand ()%5 + 1;//select random number in 1-5} if (Issandom = False)
No random display, press index_img display picture s {set_index_img = index_img;
} QString top_img_path= ":/images/top_img1.png";
Qdebug () << "[Leo]" << Top_img_path;
QImage top_img;
Top_img_path = ":/images/top_img" + qstring::number (set_index_img, ten) + ". png";
Qdebug () << "[Leo]" << Top_img_path;
Top_img.load (Top_img_path); Qpixmap top_pic=qpixmap::fromimage (top_img.scaled (Ui->label_top_img->width (),ui->label_top_img->
Height ()));
Ui->label_top_img->setpixmap (Top_pic); Qdebug () << " [Leo]top_img width heigh: "<< ui->label_top_img->width () <<" "<< ui->label_top_
Img->height (); }