I am not the best at debugging yet, so I am struggling to figure this one out. I am trying to use a custom class based on QTableView. It compiles ok, but when I try to run the program I get the following segfault:
[Thread debugging using libthread_db enabled]
[New Thread 0xb67e86c0 (LWP 23223)]
[New Thread 0xb5b97b90 (LWP 23226)]
[Thread 0xb5b97b90 (LWP 23226) exited]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb67e86c0 (LWP 23223)]
0xb77477fd in QWidget::~QWidget () from /usr/lib/libQtGui.so.4
I don't really know where to start... here is my super simple subclassed QTableView...
#ifndef APPOINTMENTBOOK_H
#define APPOINTMENTBOOK_H
#include <QtCore>
#include <QTableView>
{
Q_OBJECT
public:
AppointmentBook
(QWidget *parent
= 0);
protected:
};
#endif
#ifndef APPOINTMENTBOOK_H
#define APPOINTMENTBOOK_H
#include <QtCore>
#include <QTableView>
class AppointmentBook : public QTableView
{
Q_OBJECT
public:
AppointmentBook(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *event);
};
#endif
To copy to clipboard, switch view to plain text mode
and the cpp...
#include <QtGui>
#include <QTableView>
#include "appointmentbook.h"
AppointmentBook
::AppointmentBook(QWidget *parent
) {
//QTimer *timer = new QTimer(this);
//connect(timer, SIGNAL(timeout()), this, SLOT(update()));
//timer->start(1000);
//setWindowTitle(tr("Appointment Book"));
//resize(200, 200);
}
{
//QColor secondColor(208, 22, 13, 255);
//QTime time = QTime::currentTime();
//QPainter painter(this);
//painter.setRenderHint(QPainter::Antialiasing);
//painter.scale(width(), height() / 86400.0);
//painter.setPen(Qt::NoPen);
//painter.setPen(secondColor);
//int lineY = (time.hour()*60*60) + (time.minute()*60) + time.second();
//painter.drawLine(0, lineY, width(), lineY);
}
#include <QtGui>
#include <QTableView>
#include "appointmentbook.h"
AppointmentBook::AppointmentBook(QWidget *parent)
: QTableView(parent)
{
//QTimer *timer = new QTimer(this);
//connect(timer, SIGNAL(timeout()), this, SLOT(update()));
//timer->start(1000);
//setWindowTitle(tr("Appointment Book"));
//resize(200, 200);
}
void AppointmentBook::paintEvent(QPaintEvent *)
{
//QColor secondColor(208, 22, 13, 255);
//QTime time = QTime::currentTime();
//QPainter painter(this);
//painter.setRenderHint(QPainter::Antialiasing);
//painter.scale(width(), height() / 86400.0);
//painter.setPen(Qt::NoPen);
//painter.setPen(secondColor);
//int lineY = (time.hour()*60*60) + (time.minute()*60) + time.second();
//painter.drawLine(0, lineY, width(), lineY);
}
To copy to clipboard, switch view to plain text mode
As you can see it is all commented out because I can't figure out what's going on.
Bookmarks