// uncomment the Q_OBJECT:
// get undefined reference to `vtable for MyMainWindow'
//
// commented out: it compiles, but printmyplot() isn't called.
//
#include <QtGui>
#include <QWidget>
#include <stdio.h>
#include <unistd.h>
class MyMainWindow
: public QWidget{
// Q_OBJECT /*uncomment this to get linker error */
public:
~MyMainWindow();
void createcontent();
public slots:
void printmyplot();
private:
};
MyMainWindow::~MyMainWindow() {}
MyMainWindow
::MyMainWindow(QWidget *parent
) print_button(0),
quit_button(0)
{
resize(500,500);
setWindowTitle("QWT Simple Demo #1");
}
void MyMainWindow::createcontent()
{
bottomrow->addWidget(print_button);
bottomrow->addWidget(quit_button);
setLayout(bottomrow);
connect(quit_button, SIGNAL(clicked()),
this, SLOT(close()));
connect(print_button, SIGNAL(clicked()),
this, SLOT(printmyplot()));
}
void MyMainWindow::printmyplot()
{
printf("entered printmyplot \n");
setWindowTitle("printing...");
sleep(2);
setWindowTitle("(normal title goes here)");
prntf("returning from printmyplot \n");
}
int main(int nargs, char** args)
{
MyMainWindow *mainwindow = new MyMainWindow;
mainwindow->createcontent();
mainwindow->show();
return app.exec();
}
// uncomment the Q_OBJECT:
// get undefined reference to `vtable for MyMainWindow'
//
// commented out: it compiles, but printmyplot() isn't called.
//
#include <QtGui>
#include <QWidget>
#include <stdio.h>
#include <unistd.h>
class MyMainWindow : public QWidget
{
// Q_OBJECT /*uncomment this to get linker error */
public:
MyMainWindow(QWidget *parent=0);
~MyMainWindow();
void createcontent();
public slots:
void printmyplot();
private:
QPushButton *print_button;
QPushButton *quit_button;
};
MyMainWindow::~MyMainWindow() {}
MyMainWindow::MyMainWindow(QWidget *parent)
: QWidget(parent),
print_button(0),
quit_button(0)
{
resize(500,500);
setWindowTitle("QWT Simple Demo #1");
}
void MyMainWindow::createcontent()
{
print_button = new QPushButton("print", this);
quit_button = new QPushButton("quit", this);
QHBoxLayout *bottomrow = new QHBoxLayout;
bottomrow->addWidget(print_button);
bottomrow->addWidget(quit_button);
setLayout(bottomrow);
connect(quit_button, SIGNAL(clicked()),
this, SLOT(close()));
connect(print_button, SIGNAL(clicked()),
this, SLOT(printmyplot()));
}
void MyMainWindow::printmyplot()
{
printf("entered printmyplot \n");
setWindowTitle("printing...");
sleep(2);
setWindowTitle("(normal title goes here)");
prntf("returning from printmyplot \n");
}
int main(int nargs, char** args)
{
QApplication app(nargs, args);
MyMainWindow *mainwindow = new MyMainWindow;
mainwindow->createcontent();
mainwindow->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
TEMPLATE = app
TARGET = badslot
CONFIG += qt debug
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += badslot.cpp
TEMPLATE = app
TARGET = badslot
CONFIG += qt debug
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += badslot.cpp
To copy to clipboard, switch view to plain text mode
Bookmarks