[Interest] Can slot be virtual?

Igor Mironchik igor.mironchik at gmail.com
Mon Dec 29 06:51:49 CET 2014


Hi,

as you can see from this code:


#include <QApplication>
#include <QWidget>
#include <QTimer>
#include <QMessageBox>


class Widget
	:	public QWidget
{
	Q_OBJECT

public:
	Widget()
	{
	}

public slots:
	virtual void start()
	{

	}
};


class W
	:	public Widget
{
public:
	W()
	{
	}

	void start()
	{
		QMessageBox::information( this, tr( "Hello..." ),
			tr( "Hello from virtual slot!" ) );
	}
};


int main( int argc, char ** argv )
{
	QApplication app( argc, argv );

	W w;
	w.show();

	QTimer::singleShot( 0, &w, &W::start );

	return app.exec();
}

#include "main.moc"

Slots in Qt can be virtual. But may be there some underwater stones?

What do you know/think?

Thank you.



-- 
Best Regards,
Igor Mironchik.



More information about the Interest mailing list