void WeatherWidget::setText(const QString &widgetName, const QString &value) { QWidget* curr = ui->layoutWidget->findChild<QWidget*>(widgetName); if (curr && curr->metaObject()->className() == QString("QLineEdit") ) { if (curr->objectName() == "icon") { ui->image->setProperty("fileName", QVariant(value)); downloadImg(value); } qobject_cast<QLineEdit*>(curr)->setText(value); } }
void checkImageURL() { char address[FILENAME_MAX] = "Images\\"; // address to save images, must create an Images folder int j = 7; // number of letter based on the "folder name + \" if(letter == 1) // the number of each image is based on how many letters the board have { int initialNumber = 13, lastNumber = 26; // to get the number of each image for(int i = initialNumber; i < lastNumber; i++, j++) { address[j] = img[i]; // add image number as its name to address } } else if(letter == 2) { int initialNumber = 14, lastNumber = 27; // to get the number of each image for(int i = initialNumber; i < lastNumber; i++, j++) { address[j] = img[i]; // add image number as its name to address } } else { int initialNumber = 15, lastNumber = 28; for(int i = initialNumber; i < lastNumber; i++, j++) { address[j] = img[i]; } } regex_t *jpgregex = calloc(1, sizeof(regex_t)); //creating regex types regex_t *gifregex = calloc(1, sizeof(regex_t)); regex_t *pngregex = calloc(1, sizeof(regex_t)); regex_t *webmregex = calloc(1, sizeof(regex_t)); regcomp(jpgregex, "i\\.4cdn\\.org\\/.*\\.jpg", REG_EXTENDED | REG_NOSUB | REG_NEWLINE); // compile regex strings based on this pattern "i\4cdn\letter\number\extension" regcomp(gifregex, "i\\.4cdn\\.org\\/.*\\.gif", REG_EXTENDED | REG_NOSUB | REG_NEWLINE); regcomp(pngregex, "i\\.4cdn\\.org\\/.*\\.png", REG_EXTENDED | REG_NOSUB | REG_NEWLINE); regcomp(webmregex, "i\\.4cdn\\.org\\/.*\\.webm", REG_EXTENDED | REG_NOSUB | REG_NEWLINE); if(jpgregex == NULL || gifregex == NULL || pngregex == NULL || webmregex == NULL) { exit(0); } if(0 == regexec(webmregex, img, 0,0,0)) { strcat(address,".webm"); // webm uses one more letter, so I had to use this to add the last m on it. downloadImg(address); } else { if(letter == 1) { img[30] = ' '; } else if(letter == 2) { img[31] = ' '; } else if(letter == 3) { img[32] = ' '; } else { img[33] = ' '; } if(0 == regexec(jpgregex, img, 0,0,0)) // compare string to regex to see if has the pattern { strcat(address, ".jpg"); downloadImg(address); } else if(0 == regexec(pngregex, img, 0,0,0)) { strcat(address, ".png"); downloadImg(address); } else if(0 == regexec(gifregex, img, 0,0,0)) // save the file based on the right extension { strcat(address, ".gif"); downloadImg(address); } } free(webmregex); //free pointers free(jpgregex); free(gifregex); free(pngregex); }