I was able to create OpenGL texture from QImage with a code like this:
    QImage qImage(file_name);
    qImage = qImage.mirrored().convertToFormat(QImage::Format_ARGB32);
    GLuint Id;
    glGenTextures(1, &id);
    glBindTexture(GL_TEXTURE_2D, id);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D(target, level, GL_RGBA, qImage.width(), qImage.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, qImage.bits());
where file_name is a JPG or PNG file.
And now I am looking for way to create QImage from a texture so I will be able to save it to a PNG file with QImage::save.
Theoretically I can crate QImage with its constructor
QImage::QImage(const uchar *data, int width, int height, QImage::Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr)
but it is not clear how do I access texture data.