Goodnight! I have a strange situation here. For example, in the readMapSettings () method in waterBody.setWaterBody (mapName); I create objects and it’s very important that the geometry of the window is already fully expanded before they are created - because there inside are taken the dimensions of a QLabel with a QPixmap inside. And these dimensions should correspond to the full window (since I closed the application with the full window), which means it should also open with the full one, because I read from QSettings. But in the end, for some reason, width 100 and height 30 are written into the parameters of objects, instead of 1004 and 977, respectively. And then later this whole thing through all sorts of events comes back to normal, but with a wild overhead projector. I already even showEvent, in order to get the creation of objects after the fully expanded main window. But this does not happen, I still get 100 and 30. I first define the qpixmap, then I read the geometry, then I create the objects, what else does he need ??? Maybe there is an opportunity to somehow give the command to maximize the window right away at any cost? Just in case, I indicate that I have another important overloaded method - resizeEvent (). It is used to preserve proportions after QLabel scaleContents. But it doesn’t have to affect the problem.
void MainWindow::readMapSettings() { QSettings settings(".//settings.ini", QSettings::IniFormat); settings.beginGroup("MAPS"); const QString mapName = settings.value("map", "MosquitoLake").toString(); settings.endGroup(); if(mapName == "CottagePond") { ui->labelImageMap->setPixmap(QPixmap(".//maps/Hootorez_CottagePond.jpg")); waterBody.setLabelImageMapPtr(ui->labelImageMap); readDisplaySettings(); waterBody.setWaterBody(mapName); writeMapSettings(mapName); } } void MainWindow::showEvent(QShowEvent *event) { QMainWindow::showEvent(event); readMapSettings(); } void MainWindow::resizeEvent(QResizeEvent *event) { if(!waterBody.getLabelImageMapPtr()) return; int widthCurrentPixMap = 1; int heightCurrentPixMap = 1; const QPixmap* pixPtr = this->ui->labelImageMap->pixmap(); if(pixPtr) { widthCurrentPixMap = pixPtr->width(); heightCurrentPixMap = pixPtr->height(); } const QSize pixmapSize(widthCurrentPixMap, heightCurrentPixMap); ui->labelImageMap->setFixedWidth( ui->centralWidget->height() * pixmapSize.width() / pixmapSize.height() ); QMainWindow::resizeEvent(event); }
sizeHint()override. This parameter is responsible for the preliminary (recommended) dimensions. - Madisson