1 Attachment(s)
Urgent Help regarding Line numbering
I have been posting various threads but not able to get a fruitful reply. I have been trying to introduce line numbering in a text edit..I would like to post all the code that i have done till now.
mainwindow.h
Code:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include<frameclass.h>
#include <QMainWindow>
#include<frameclass.h>
#include<Painter.h>
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.cpp
Code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<qtextcursor.h>
#include<frameclass.h>
#include<qpainter.h>
#include<Painter.h>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
I have created a separate class "frameclass.h" to implement paint event.
frameclass.h
Code:
#ifndef FRAMECLASS_H
#define FRAMECLASS_H
#include<QWidget>
#include<QFrame>
#include<qpainter.h>
#include<qmainwindow.h>
#include<QTextBlock>
class frameclass
: public QFrame{
Q_OBJECT
public:
{
}
{
p.setPen(Qt::red);
p.drawText(r, Qt::AlignCenter, "hello");
//p.drawRect(r);
p.fillRect(r,Qt::lightGray);
//p.drawLine( rect().topLeft(), rect().bottomRight() );
//p.drawText( rect().center(), "works!" );
}
};
#endif // FRAMECLASS_H
frameclass.cpp
Code:
#include "frameclass.h"
frameclass::frameclass()
{
}
For line numbering, I have been following this example.
http://qt-project.org/doc/qt-4.8/wid...odeeditor.html
This is how my Ui looks like...
Attachment 9842
Can anyone please help me out with this so as to how can i introduce line numbering??
Re: Urgent Help regarding Line numbering
Why don't you just copy the class CodeEditor from the example and use it as it is.
Re: Urgent Help regarding Line numbering
@Santosh Sir, I would have copied the entire code if there if I would have required only one textedit and its line numbers. I have a Ui containing multiple widgets as i posted in the previous post the image of my Ui.. I wish to pass the Ui object of textedit to the CodeEditor class. Can you suggest me how to do this? This is mainly what I am looking for. Any help would be appreciable.
Re: Urgent Help regarding Line numbering
I am not able to understand your requirement.
Quote:
I have a Ui containing multiple widgets as i posted in the previous post the image of my Ui..
The UI you posted is a MainWindow containing a textedit. Where are the multiple widgets in it?
Quote:
I wish to pass the Ui object of textedit to the CodeEditor class. Can you suggest me how to do this?
CodeEditor itself is a textedit. What is the UI you are talking about?
1 Attachment(s)
Re: Urgent Help regarding Line numbering
@Santosh Sir, sorry I posted wrong image. This is the updated one..Attachment 9844..with multiple widgets..
Re: Urgent Help regarding Line numbering
Looks like you want to insert CodeEdit from Qt Designer, If yes you have two options.
1. Make a Qt Designer plungin for CodeEdit
or
2. Add a regular QWidget in UI and promote it to CodeEdit.
Re: Urgent Help regarding Line numbering
Thank you very much @Santosh Sir...was stuck at this from so long.. Finally able to do it... Thanks a lott....:)
Re: Urgent Help regarding Line numbering
@Santosh Sir, I have one more question. Sorry posted a few threads about this but didn't get any replies so I am continuing this thread. I have a doubt regarding regular expressions.
Can we write a single piece of code for all the operators instead of writing code for each and every operator to include them as a regular expression?
I wish to initialize rx in such a way that it should include all arithmetic operators. Is there a way out for this? Can nyone please help me out?
Re: Urgent Help regarding Line numbering
You have already asked this question (and several others like it) in its own thread. You received a response asking you to define the problem better and giving you a suggestion on how to improve your understanding... that you just ignored. I suggest you start reading responses you get rather than simply asking the same questions over and over until someone gives you something you can copy and paste without understanding.