PDA

View Full Version : how to debug with qt



rafik
12th February 2016, 20:23
hello,
i want to know how to debug with Qt because i want to execute this code but it gives an error.
imageViewer.h


#ifndef IMAGEVIEWER_H
#define IMAGEVIEWER_H
#include<QtWidgets>

class ImageViewer : public QMainWindow
{
Q_OBJECT
public:
ImageViewer();
public slots:
void ouvrir();
private:
QLabel *label;
QImage *image;
QVBoxLayout *layout;
};

#endif // IMAGEVIEWER_H

imageViewer.cpp


#include "imageviewer.h"

ImageViewer::ImageViewer(): QMainWindow()
{
label = new QLabel(this);

label->move(100,100);
label->setFixedSize(500,500);
layout = new QVBoxLayout(this);
layout->addWidget(label);
this->setLayout(layout);
QMenu *fichier = menuBar()->addMenu("Fichier");
QMenu *edition = menuBar()->addMenu("Edition");

QAction *ouvrir = new QAction("Ouvrir",this);
fichier->addAction(ouvrir);
connect(ouvrir,SIGNAL(triggered(bool)),this,SLOT(o uvrir()));



}

void ImageViewer::ouvrir()
{
QString nomFichier = QFileDialog::getOpenFileName(this,"Open file", "C://");
image = new QImage(nomFichier);
label->setPixmap(QPixmap::fromImage(QImage(nomFichier)));
}

and the error is
cannot open output file debug\app.exe: Permission denied
error: ld returned 1 exit status

Thank you.

ChrisW67
12th February 2016, 20:50
There is still a copy of your executable running, which will block any attempt to rewrite the exe. Open Windows task manager and find the app.exe to terminate or show it.

This situation can arise if the program main() has been constructed to not exit when the last window closes.

You can use the debugger matching your toolchain (gdb or cdb) to single-step, breakpoint, and inspect a debug build of your program. This function is essentially independent of Qt itself, although your IDE can typically help with the launch, control and display of the resulting debug session. You cannot do this if you cannot build the program you intend to run.

rafik
12th February 2016, 21:00
after restarting the copy is removed, but for the debug are there any good tutorial to understand what is the toolchain and the breakpoints? because i am not familiar with this.