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); } 
  • and you can write the main idea, because It seems that the approach you have chosen is clearly not the one. - Madisson
  • Well, the main idea is to get the correct coordinates when creating objects at the start of the program. Coordinates depend on the current window size. Because qsettings saves the geometry to a file, and I read the file when I start, so I have to get the coordinates for the geometry that is read from the file. Geometry works, but for some reason the window unfolds later than I create objects, which means I am not getting the correct coordinates for the current window, despite the seemingly correct sequence of operations. - FliXis
  • It’s not quite clear why you tie the coordinates to the size of the window (if we are talking about coordinates on the map). But if you want to adjust the original dimensions, you need to look in the direction of the sizeHint() override. This parameter is responsible for the preliminary (recommended) dimensions. - Madisson
  • In my case, there’s nothing more to tie them to except for the coordinates of the QLabel. (I keep the percentage in the file). Pre-sizes don't suit me. In what size the user closed the program, in this it should be restored, for such a size the coordinates should be calculated immediately after the start of the program. - FliXis
  • Take as an example gugul cards. The scale of the map there does not change depending on the size of the browser window. Then you need to be attached to the size of the picture itself (the original size) and then scale it up. I wonder how the map scaling and movement works for you if you use only a label. - Madisson

0