Qt-interest Archive, December 2006
problem subclassing
Message 1 in thread
I posted this on the qtforum, but got no specific help (in fact, I was
told it should work).
----------------------------------
Trying to subclass QTable for a number of reasons. One thing I want to
do is reimplement selectCells(), selectColumn(), and selectRow(). To
test, I simply had them print to cout that the program was that routine,
and do nothing to the GUI. I fire it up, and all of the above seem to
be behaving normally. IE -- I'm not overriding those functions, like I
think I should be. I am calling these functions, obviously, but
selecting cell(s) and/or columns.
header file:
#ifndef TABLE_H
#define TABLE_H
#include <qtable.h>
class table : public QTable
{
Q_OBJECT
public:
table( int rows, int cols, QWidget *parent = 0, const char *name = 0
) : QTable( rows, cols, parent, name ) { };
~table() { };
void selectCells( int, int, int, int );
void selectColumn( int );
public slots:
private slots:
private:
};
#endif
implementation:
#include "table.h"
#include <iostream>
#include <qpainter.h>
using namespace std;
void table::selectCells( int start_row, int start_col, int end_row, int
end_col)
{
cout << "in select cell" << endl;
}
void table::selectColumn( int col )
{
cout << "in selectColumn() " << endl;
}
how I call it:
tbl = new table( 0, 8, this );
tbl->setLeftMargin( 0 );
tbl->setShowGrid( FALSE );
// .. do some other stuff to make it pretty.
--
[ signature omitted ]
Message 2 in thread
Paul England a écrit :
> I posted this on the qtforum, but got no specific help (in fact, I was
> told it should work).
>
> ----------------------------------
> Trying to subclass QTable for a number of reasons. One thing I want to
> do is reimplement selectCells(), selectColumn(), and selectRow(). To
> test, I simply had them print to cout that the program was that routine,
> and do nothing to the GUI. I fire it up, and all of the above seem to
> be behaving normally. IE -- I'm not overriding those functions, like I
> think I should be. I am calling these functions, obviously, but
> selecting cell(s) and/or columns.
>
> header file:
>
> #ifndef TABLE_H
> #define TABLE_H
>
> #include <qtable.h>
>
> class table : public QTable
> {
> Q_OBJECT
> public:
> table( int rows, int cols, QWidget *parent = 0, const char *name = 0
> ) : QTable( rows, cols, parent, name ) { };
> ~table() { };
>
> void selectCells( int, int, int, int );
> void selectColumn( int );
>
> public slots:
>
> private slots:
>
> private:
> };
>
> #endif
>
>
> implementation:
> #include "table.h"
> #include <iostream>
>
> #include <qpainter.h>
>
> using namespace std;
>
> void table::selectCells( int start_row, int start_col, int end_row, int
> end_col)
> {
> cout << "in select cell" << endl;
> }
>
> void table::selectColumn( int col )
> {
> cout << "in selectColumn() " << endl;
> }
>
>
> how I call it:
>
> tbl = new table( 0, 8, this );
> tbl->setLeftMargin( 0 );
> tbl->setShowGrid( FALSE );
> // .. do some other stuff to make it pretty.
>
Hi,
Those functions are not declared virtual in QTable, so I don't think
such reimplementation is possible.
Denys
--
[ signature omitted ]
Message 3 in thread
Aaah, I see. Will have to figure out away around these.
Having issues reimplementing some other stuff, but will have to look a
bit deeper.
Anyways, thanks.
>
> Those functions are not declared virtual in QTable, so I don't think
> such reimplementation is possible.
>
> Denys
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]