Qt5 Gui Element loading delay

Viewed 543

I have searched for this topic but I seemingly cannot find a good solution for the following issue (for example discussed here):

I am currently doing some tutorials to get the hang of it. During the course of my trials, I now have a very simple Qt5 test GUI. The program itself starts very fast and the window immediately shows up, but the QPushButton is displayed with a 1-2 second(s) delay.

Here is the code i am using:

MainWindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPushButton>

class MainWindow : public QMainWindow
{
    Q_OBJECT
    public:
        explicit MainWindow(QWidget *parent = nullptr);
    private slots:
        void handleButton();
    private:
        QPushButton *btnExit;
};

#endif // MAINWINDOW_H

MainWindow.cpp

#include "MainWindow.h"

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    btnExit = new QPushButton("Exit", this);
    btnExit->setGeometry(QRect(QPoint(0, 0), QSize(75, 25)));
    connect(btnExit, SIGNAL(released()), this, SLOT(handleButton()));
}

void MainWindow::handleButton()
{
    this->close();
}

main.cpp

#include "mainwindow.h"
#include <QApplication>

using namespace std;

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    MainWindow mainWindow;
    mainWindow.show();
    return app.exec();
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.17)
project(qtgui)

set(CMAKE_CXX_STANDARD 14)

# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui)

set(SOURCE_FILES main.cpp MainWindow.cpp MainWindow.h)
add_executable(qtgui ${SOURCE_FILES})
target_link_libraries(qtgui Qt5::Core Qt5::Widgets Qt5::Gui)

I have a running Mingw64 environment in msys2 on Windows 10 with a fairly decent Laptop (8thGen I5 and an NVM), so speed should not be the issue here.

UPDATE

Here is a gif that shows the phenomenon:

click_me

I've also noticed the following warnings of my IDE (CLion):

qt.qpa.fonts: Unable to enumerate family ' "Droid Sans Mono Dotted for Powerline" ' qt.qpa.fonts: Unable to enumerate family ' "Droid Sans Mono Slashed for Powerline" ' qt.qpa.fonts: Unable to enumerate family ' "Roboto Mono Medium for Powerline" ' qt.qpa.fonts: Unable to enumerate family ' "Ubuntu Mono derivative Powerline" '

Could it be that fonts cause this delay?

0 Answers
Related