

It is a "vis maior" and you can hardly do anything to protect your app when this situation comes.
#QT IMAGE VIEWER INSTALL#
Unless you create mission critical apps, you do not need to worry about running out of memory. Install lximage-qt by entering the following commands in the terminal: sudo apt update sudo apt install lximage-qt. If I were you, I would care more about systematic memory leaks, where you forget to release memory under NORMAL circumstances. So unless you create really bullet-proof mission critical apps, your probably do not need to care about such situation. It has many useful features, such as filesystem browsing, slide show, image catalogs, web album creation, camera import, image CD burning, batch file operations and quick image editing features like transformation and color manipulation. Your program will malfunction anyway if you completely run out of memory. gThumb is an advanced image viewer and browser.
#QT IMAGE VIEWER CODE#
Of course, you can try to solve partial piece of code with smart pointers but it still probably leaves lots of leaks inside Qt library itself. You are probably going to crash or complete freeze your computer anyway and restart will be necessary. Some memory leak is your least concern in such a situation. dynamic allocation) fails, then this means there is something really terrible going on: all your memory is exhausted and not even swapping memory to disk helps solve it. Well, this is probably overall a problem of Qt because it is not completely exception safe įrom practical point of view it does not matter unless you create mission critical apps. If yes, what is the canonical way to solve this? However, during construction, if the imageLabel creation were to succeed, but the scrollArea creation were to fail, would the imageLabel not be leaked? Likewise for setCentralWidget(scrollArea) where the window takes ownership of the scrollArea. I understand that in the line scrollArea->setWidget(imageLabel) the scroll area takes ownership of the imageLabel pointer and will delete it when required. Where imageLabel and scrollArea are pointers members to a QLabel and QScrollArea respectively. Resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5)

ScrollArea->setBackgroundRole(QPalette::Dark) ImageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored) ImageLabel->setBackgroundRole(QPalette::Base) A Image Viewer Example on the QT documentation website contains the following code snippet: ImageViewer::ImageViewer()
