Important: Please read the Qt Code of Conduct -

Qt5.7 msvc2015 debugger don't work

  • Hi, I want to run my app in debug mode with Qt 5.7 and msvc2015 and I have a problem, debuger don't work. Please help me with this. I have installed newest Windows debugging tools from Windows SDK, but when I'm trying to debug my app, Error: The program has unexpectedly finished.

    Scrrenshots from Qt Settings:

    Thank you for any help :)

  • Lifetime Qt Champion


    Do you have any external dependency in your application ?

    Did you install the latest updates of Visual Studio ?

  • Hi, I have checked and tried to debug another project, and suprisely I can debug another apps.
    In my application I don't use anything special.
    Please help me with this stupid issue :(

  • Lifetime Qt Champion

    It can debug other Qt app ?

  • Hi km2442,

    if you can debug other applications, the error The program has unexpectedly finished
    my be caused by your application. This could be anything, from access to nullpointer over stack corruption to uncaught exceptions. Try to set a breakpoint as early as possible and narrow the error.

  • @SGaist Yes, I can debug any other app.
    @sneubert Hi, I have setted brakpoint at 1st line of my app main.cpp before int main(). It is

    #include "mainwindow.h"

    And still the same error: The program has unexpectedly finished

    Edit: no matter where I place breakpoint, evrywhere the same effect

  • Are there any global objects, where the constructor get´s called?

  • Do you mean 'extern' objects? If yes, My program contains some extern functions, and extern variables, but no classes.

  • Ok, this is getting difficult. Maybe you can share some code.

  • As you asked, I'm sending my includes and fragment of main
    My includes:
    This file (funkcje.h) contains most of includes.

    #include <string>
    #include <sstream>
    #include <windows.h>
    #include <time.h>
    #include <thread>
    #include <shlobj.h>
    #include <winnls.h>
    #include <shobjidl.h>
    #include <objbase.h>
    #include <objidl.h>
    #include <shlguid.h>
    #include <atlbase.h>
    #include <QFileDialog>
    #include <QFile>
    #include <QStyleFactory>
    #include <QTimer>
    #include <QDebug>
    #include <QCloseEvent>
    #include <QDesktopServices>
    #include <QMenu>
    #include <QTableWidgetItem>
    #include <QSystemTrayIcon>
    #include <QSettings>
    #include <QTranslator>
    #include <QProcess>
    #include <QFileDialog>
    #include <QInputDialog>
    #include <QCryptographicHash>

    And fragment of main.cpp (I don't know if something could be wrong here, I'm sending at least 30% of all coe from this file):

    #include "mainwindow.h"
    #include "funkcje.h"
    int main(int argc, char *argv[])
        if (argc == 2)
    	QtSingleApplication a(argc, argv);
        QSettings myapp(QSettings::IniFormat, QSettings::UserScope, "AutoSwitch", "application");
        appData = QFileInfo(myapp.fileName()).absolutePath();
        QSettings setting(appData + "/config/settings.ini", QSettings::IniFormat);
        QTranslator tra;
        if (setting.value("/Language").toInt() == 2)
            if (tra.load(":/translations/Resources/Languages/English.qm"))
    	MainWindow w;
    	QObject::connect(&a, SIGNAL(messageReceived(QString))
    	, &w, SLOT(onMessageReceived(QString)));
    	if (hide == true && argc > 2) w.hide();
    	int ret = a.exec();
    	QObject::disconnect(&a, 0, &w, 0);
    	return ret;

  • Lifetime Qt Champion

    Nothing obvious from the code you shared.

    However, your settings handling is going to bite you when you release your application. Don't write data in the same folder as your application. If you install your application on Windows, your users won't have the rights to do so and even if they would, multiple users would access the same settings triggering security and privacy hazards. Use QStandardPaths to get a suitable path to store these files or simply let Qt handle it for you.

  • As in funkcje.h there are only system/framework headers and the application crash is before the first line in int main the last chance is your mainwindow.h. Could you post it?

  • One more thing: My application is using one external library: Qtsingleapplication It is wrote for Qt4, so maybe there is a problem...?

    @SGaist I store settings of my application in every user appdata folder, so settings are safe and separated :) One simple question about that, where should I store global settings of my app (where every user can access easly without administrator permissions)?

    @sneubert Ok, I can share most of my mainwindow.h
    One more info: I have placed breakpoint at first line of mainwindow.h before any code and again debugger crashed.

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include <QMainWindow>
    #include "funkcje.h"
    namespace Ui {
    class MainWindow;
    class MainWindow : public QMainWindow
        explicit MainWindow(QWidget *parent = 0);
        QSystemTrayIcon *trayIcon;
        void tray();
        void showMainWindow();
    private slots:
    **I have deleted simple functions() without arguments**
        void onMessageReceived(const QString &message);
        void on_ActiveTasks_Tab_cellClicked(int row, int column);
        void iconActivated(QSystemTrayIcon::ActivationReason reason);
        void on_tabWidget_currentChanged(int index);
        Ui::MainWindow *ui;
        void MainWindow::closeEvent(QCloseEvent * event);
        void MainWindow::urywanie(bool u);
        void timeUpd();
        bool TaskState();
        Settings *settings;
        QMessageBox message;
        QMenu *trayIconMenu;
        QAction *exampleQAction_Tray;
        QMenu *exampleQmenu_Tray;
    #endif // MAINWINDOW_H

  • Lifetime Qt Champion

    You should rather use the official QtSolution repo github is merely a mirror.

    What do you mean by global settings ? Also what OS are you running ?

    Are you sure that you have everything initialized before using anything ?

  • I have newest Windows 10 x64.
    I need global settings for eg. when admin sets some tasks and turn on autorun on every account, so my app can run even without current user settings. But now I use stupid localisation of global settings files (C://myapp)

    Release version of my app works very well, so I believe that I initialised everything good.

  • Lifetime Qt Champion

    AFAIK, that's rather the task of the registry.

  • I didn't think about registry, thank you :)
    BTW, what about debugger?