View Full Version : Qt line number in text editor
Nyx
23rd August 2010, 19:47
Hello;
I have been looking for my issue for somes weeks but I didn' achieve to solve it.
I'm trying to put line numbers on the left side of my QSubWindow but I have a compilation error using the Qt exemple (http://doc.qt.nokia.com/4.5/widgets-codeeditor.html): 'QWidget' is an ambiguous base of 'MainFen'
I don't understand the error.
Could you help me please?
Lykurg
23rd August 2010, 19:57
MainFen has which base classes? Please show some code that we better can see, what you are doing wrong.
Nyx
24th August 2010, 07:51
oh sorry :
class MainFen : public QMainWindow, public QPlainTextEdit, private Ui::MainFen
{
Q_OBJECT
public:
MainFen(QWidget *parent = 0);
~MainFen();
void lineNumberAreaPaintEvent(QPaintEvent *event);
int lineNumberAreaWidth();
private slots:
void updateLineNumberAreaWidth(int newBlockCount);
void updateLineNumberArea(const QRect &, int);
protected:
void resizeEvent(QResizeEvent *event);
private:
QMdiArea * centralZone;
QMdiSubWindow * Win;
QPlainTextEdit * textEdit;
QWidget * lineNumberArea;
};
So MainFen has public QMainWindow, public QPlainTextEdit, private Ui::MainFen base classes.
and that's the LineNumberArea class from Qt exemple:
class LineNumberArea : public QMdiSubWindow
{
Q_OBJECT
public:
LineNumberArea(MainFen * main) : QMdiSubWindow(main)
{
mainfen = main;
}
QSize sizeHint() const
{
return QSize(mainfen->lineNumberAreaWidth(), 0);
}
protected:
void paintEvent(QPaintEvent *event)
{
mainfen->lineNumberAreaPaintEvent(event);
}
private:
MainFen * mainfen;
};
Ginsengelf
24th August 2010, 07:59
Hi, MainFen is derived of two QWidget based Widgets: QMainWindow and QPlainTextEdit. I am not sure if that is allowed at all.
Ginsengelf
Nyx
24th August 2010, 08:27
Yes this is not allowed but how should I do?
Ginsengelf
24th August 2010, 09:08
Just derive from QMainWindow only and use QPlainTextEdit as a member (you already have the pointer).
Ginsengelf
Nyx
24th August 2010, 10:16
If I only inherit from QMainWindow I have other errors other errors (http://img291.imageshack.us/i/errorkw.png/)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.