Reputation: 81
I'm guessing the answers to these questions will be very simple to anyone familiar with Qt. I'm trying to follow this intro tutorial for Qt: http://doc.qt.nokia.com/4.7-snapshot/gettingstartedqt.html. I get it up until the part that I've taken this screenshot for:
http://i160.photobucket.com/albums/t182/thinkpad20/qtintro.jpg
I understand these two code blocks well enough, but if I implement the widget as a class like they show here, what should I be putting in the main function of my code? It doesn't say anywhere. Also, when I try to compile this code, I get a "undefined reference to 'vtable for Notepad'" error. Can anyone help me out?
Upvotes: 1
Views: 140
Reputation: 4424
undefined reference to 'vtable for Notepad'
almost certainly means you're not linking in the moc-generated files. The Qt docs mention it as a common mistake.
As for what to include in main
, it normally involves the creation of an Application and a GUI element, then calling exec on the application. At its most basic, it might look like this:
#include <QApplication>
#include "notepad.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Notepad mainWindow;
mainWindow.show();
return app.exec();
}
Upvotes: 3