Simple text editor in Qt/C++ [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I would like to write a simple text editor. I would like it to be GUI-based, and written using Qt.
Qt provides the class QTextEdit, which is a pretty fully-featured text editor (it supports ctrl+c, x , and z, text highlighting, and moving the cursor around left-right-top-down). I would like to write something similar, but I would like to implement all this functionality from scratch.
So my requirements are:
A simple window.
Be able to read text from a user, and output the prepared file to the screen.
The user must be able to access the text for editing.
I have taken a look at the source code to qtextedit.cpp from the official Qt site to get some idea of how this was implemented. Unfortunately I am not experienced enough to understand it (there are nearly 4000 lines of code, and many macros).
How might I make some progress with my project?

I think you are best off taking a look at some of the code here: http://kde-apps.org/index.php?xcontentmode=241
Take a look at the code, try coding something of your own, and realise that Qt requires one to know C++ fairly well. You will, at the very least, need to understand classes and pointers. If that feels manageable, then the best way is generally to try: you'll run into some problems, and then you can see how other people have solved that problem.
I think the most specific advice I can give is to write tests for everything that looks like it can reasonably be tested, that may save you some debugging time. Other than that, there's little more to say without example code and a more specific question.

This is a major job of work. If you want a decent editor, you are more or less forced to start with the Scintilla edit control, because it's simply the best (and it comes with a Lesser General Public Licence). But then you have to implement an editor on top of it. You don't really want to do this (trust me), so you have to use an existing open-source editor. The best of these is probably Notepad++, which has way more than 4000 lines of code. It comes with a General Public Licence, which is not compatible with the project I'm currently working on, so I ended up using the SciTE editor instead. I have implemented an interface for this which lets me embed it in a Qt application, and it works like a charm. In the next two or three months I hope to get this interface accepted by the SciTE community and incorporated into the official release. Meanwhile, if you are not bound by the licensing requirements, you might want to look at QScintilla.

In the Qt Demo application there is an MDI text editor that teaches a lot (http://doc.qt.nokia.com/latest/mainwindows-mdi.html).

Related

Image anlaysis in C/C++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm rather novice in C++ and I must realize this schoolar project :
Assume an image in a document containing both texts and images.
There should be a program written in C++ whose the goal is to load the document and extract separately texts and images in order to output it in
some target destinations like UI or file.
Furthermore, if image contains any texts like legends, program should be able to extract it separately too.
Is there an existing c++ library that respond to those requirements ?
Yes, OpenCV.
http://sourceforge.net/projects/opencvlibrary/
No doubt in that, use OpenCV.
But remember, you have a long way to go.
1. First of all, you should be good in C++ and object oriented programming.
Well, if you are not good, try to learn it first. Check out following link for some best resources : https://stackoverflow.com/questions/909323/what-are-good-online-resources-or-tutorials-to-learn-c
2. Then get OpenCV and install
Check out OpenCV homepage to get info about downloading and installing OpenCV.
3. Now get and read some good books on OpenCV
The best book on OpenCV is "Learning OpenCV" written by Gary Bradsky, main founder of OpenCV.
Second one is "OpenCV cookbook".
These books contains lots of examples on OpenCV along with description
4. Check out OpenCV documentation.
OpenCV documentation contains details of complete functions. It also includes a lot of tutorials, which are really good for all.
5. Also try running OpenCV samples. It contains a lot of good programs
And always, Google is your best friend. Ask everything there first. Come here only when you are lost in your path.
Acquire all the above things. Then you will be really good in OpenCV and i am sure you will enjoy its power. Once you are done with these, you will get enough idea on realizing your project.( Otherwise, you will post new questions every day asking codes to realize your project, which will be useless for you. )
For your understanding, your project include advanced things like Optical Character Recognition. It is a big topic. So build yourself from basics. And it will take time.
All the best.

What is a good iPhone UI framework for a chess like game? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am trying to develop a chess like game for iphone/ipad, I have developed the internal game logic using objective-c and c++ , that's fine but I am wondering what's the possible ways to develope a good GUI on iphone/ipad ?
As far as I know I could use Core Graphic, cocos2d.
Are there any more ?
And which one might be best suitable for chess like game?
(e.g display a fixed board, add chess piece to the board, remove piece from board, move piece around on board)
If my question was causing come confusing, I have rephrased it, hope this makes it a bit clearer.
Many thanks
For game frameworks, the obvious one is cocos2d.
Having almost finished a - relatively - simple 2d game, I would highly recommend using a framework like cocos2d. With Core Animation you can do a lot of amazing stuff. However, for game type scenarios, you hit problems that Core Animation doesn't solve.
For example, what if the user gets a call during the game right in the middle of an animation? You'll have to handle all that manually. I mean, you'll have to check the state of thepresentationLayer, update the model layer, save all the state, then reconstruct it all when the app moves to the foreground again.
For this sort of issues, I'd seriously consider a game framework.
There are alternatives to cocos2d, e.g. Kobold2D. So definitely have a look around.
A couple of GUI apis.
CoconutKit - When designing components, I strongly emphasize on clean and documented interfaces, as well as on code quality. My goal is to create components that are easy to use, reliable, and which do what they claim they do, without nasty surprises. You should never have to look at a component implementation to know how it works, this should be obvious just by looking at its interface. I also strive to avoid components that leak or crash. If those are qualities you love to find in libraries, then you should start using CoconutKit now! Moreover, CoconutKit will never use any private API and will therefore always be AppStore friendly.
Three20 - Three20 is a open source Objective-C library used by dozens of well-known brands in the App Store, including Facebook, Posterous, Pulse, Meetup.com, and SCVNGR. Three20 provides powerful view controllers such as the Launcher, the popular Photo Browser, and internet-aware tables.
tapku - Tapku Library is an open source iOS framework built for iPhone & iPad. The framework includes popular API's including coverflow, calendar grid and chart view. The framework also has tidbits of code that will make iPhone and iPad development all the more enjoyable and faster. Integrating the framework is easy and can be incorportated right into your applications now. Try out the demo to see some of the things you can take advantage of in the framework.
Direct comments from their sites.

Funding for MathML rendering library [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have an unfinished MathML rendering library written in C++. I ceased development a few months ago due to lack of time. The library [still] uses the TrueType version (unsupported) of the STIX fonts beta [version 1.0 of the STIX fonts (OpenType Postscript format) has since been released].
Development of this kind of library is a HUGE undertaking and, in fact, requires a number of programmers/developers. In my case, I am doing it alone, and here's my question:
Does anyone of you know of any foundations/philanthropists who may be interested to fund my project in return for open sourcing the code?
The funding will serve as an incentive for me to finish the library - perhaps by taking a sabbatical :p - and, of course, as 'payment' for the intellectual property involved.
I've searched the web, contacted some [e.g., foundations, VCs, angels, etc.], but I either did not get a response (from VCs and angels) or was rejected (one reason is geography since these foundations support only US-based projects).
As an aside, when I search the web for MathML, the results are often outdated. I guess there's not much activity concerning MathML. Yet, I believe this library will be very useful not only to developers but also to anyone who uses math, especially students and teachers. It is useful for e-learning, can be used with desktop apps and web servers (Windows), makes it easy to insert images of formulas in PowerPoint documents, etc.
Any suggestions are most welcome. Thank you.
EDITS: I have finished this library finally without funding, although I don't rule out seeking one.
You can find my new site below with lots of sample formulas; click on the download link to download the SDK.
http://reformath.webnode.com/ (preferred for statistical reason)
http://reformath.weebly.com/ (please use the above link instead)
DON'T forget to provide some feedback - or donations. Thanks!!!!!
Since we've already got open source MathML (Firefox has had it for years) that mean you'd have to do something better than the existing OSS solutions. And at that point, why not work on an existing open source project?
So that leaves commercial apps that may want a closed library for MathML rendering. I would go after companies like the makers of MathCad, Matlab, or any other engineering software that may want to display equations neatly. You should have something that already works for some subset of the things you/they will want it to do. You should also turn yourself into a company before going to those places so they take you seriously and you can license it to multiple customers. Otherwise the most you're likely to get is a job offer where they'd like you to hand over what you've got (for free if they can get you to) and then work on it as an employee - which may be all you want if you love it and hate your day job ;-)
You should probably ask on www-math list, also if you ask there, we can list your application in the software implementations page
http://www.w3.org/Math/Software/

I want to make my own source code editor, what are the good choices to make? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I've had it of those dozens of editors which never provides simple things like:
distinguish type keywords and instruction keywords so I can put different colors on them.
being cross platform using a standard GUI lib like qt gtk etc (notepad++, yes, I almost hate you).
enough keyboard shortcut like duplicate line, comment selection, and a decent find-replace.
Decent task-easing features like single-click-on-the-number-line-margin to select the entire line.
Scintilla or another good-enough lexer that highlights enough different things, because brain-compiling code is one thing, quickly identify with the eyes what is what is something I find important.
I just want to support very basic languages like C, C++, maybe Python, not HTML or CSS.
Is Scintilla a good choice to just highlight those languages, and is a lexer really necessary ?
Isn't QT enough to program a text editor such as the one I want to do ? I know there is QScintilla, but is there a reason I shouldn't use a lib that integrates a lexer ? Why is Scintilla such a good lib ?
Is QT a good choice for such an editor ? (I also want to hard embed ProFont in the editor to kill any reluctant font problem between OSes).
EDIT:
In short, I want to make an editor, only with the same syntax highlight features of notepad++. That's my main goal, and the use of QScintilla might be a little harder than I thought...
EDIT2:
Well I found textadept, it's not so known but is quite awesome. I didn't manage to make my lexer, since I have other to do which I do under windows, unfortunately it's slow on the mac. Apparently there isn't any Scite official build for the mac.
C++ is not a "very basic language" by any stretch of the imagination.
Why do you really want to do this? There are SOOO many open source code editors out there.
If you must write your own editor, I suggest looking at the other open source editors and examine which pieces you port to your editor.
Porting pieces of existing working and tested code is usually much better than writing your own code and debugging it.
After perusing a couple serious open source editors: Emacs, Eclips, CodeBlocks, CodeLight, etc., I believe you will start changing your mind about writing an editor from scratch.
-- Thomas Matthews
My Info
If you really want to do this (and it sounds like a lot of work) I would look at ANTLR for parsing the code. You may get some ideas from their ANTLRWorks display.
To link the parse tree to a display could be a fair amount of work so I'd see what an IDE platform such as Eclipse has to offer
Are you OK with Java?
If so, go for Eclipse technologies: SWT and JFace. The latter provides you with org.eclipse.jface.text package with a lot of features. Then you can roll own editor easily basing on that. (I prefer Eclipse-based editors to Scintilla-based, I believe they tend to be more advanced and feature-rich, but that's my personal opinion.)
But then, you might want to go a step further and use the Eclipse RCP framework for you application... But then why not use the Eclipse IDE itself and just add whatever you want as plug-ins.
The Eclipse codebase is huge and it's up to you how much you want to reuse.
I would expend some effort experimenting with the emacs colour theme package and the various langauge modes; see if you can bend the lisp to do what you want. You almost certainly can. to my mind emacs and a bit of effort on your part will get you your ultimate editor (remember emacs is really just a DIY editor toolkit). If you cant bend emacs into the shape you want you will be well placed to expend the effort in writing your own.
I have tried to do something similar myself for a project I'm working on at the moment, I looked into the QScintilla and had to remove it from my project because when you embedded inside a QGraphicsView I can't control the resolution of the widgets image, it seems to paint the text as an image and that's what we see, I played with increasing the smoothness of the QFont and that improved it but still a no-go.
So I found a simple code editor inside QT's code base it comes with every installation of QT if you look
into:
C:\Qt\4.7.3\src\scripttools\debugging\qscriptedit.h
C:\Qt\4.7.3\src\scripttools\debugging\qscriptedit.cpp
If you go to the source code of OpenShapeFactory where I'm trying to embed a Code Editor: check how I got the syntax Highlighter and the autocomplete :
this widget uses the qscriptedit widget that ships with qt, you can add your own keywords to the syntax hightlighter from a file as well as for the auto-complete dropdownlist.
this is the header, scriptwidget.h and the implementation scriptwidget.cpp are available as part of the whole project code.
the next stage is to look into the QTCreator and see the code they already have all if not most of these features after you get to compile their version, just find where to add your little mods and you might be getting closer to the simple code editor.
I wish you the best of luck on this direction and if you find a solution please send it over, :)
heads-up keep a lookout for the repository link above, if I find a way of making it first, I might chase you to the answer.
Like everyone else is saying, it's probably more trouble than it's worth, but if you really want to do it, Qt's a good choice since it's cross platform. Use QSyntaxHighlighter to do your keyword/type highlighting, and take full advantage Qt's support for keyboard shortcuts.
use something like C, QT and Lua for the scripting engine.

how to write a text editor in c++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I learned c++ on and off for several times but never write a real apps using it .
long time I've been thinking that writing a text editor will be something very interesting , now I am looking for a simple but decent text editor written in c or c++ from which I can get inspiration and learn how to write a text editor by myself.
Could you guys recommend a "simple but decent" text editor written in c or c++ to me ?
You might want to look at Zile or nvi. Both are fairly simple; Zile is Emacs-like, and nvi is the Berkeley vi. Another to look at would be Nano, a simple text editor that is designed to be easy for new users. I don't know how clean the code is on any of these, though.
I would also recommend reading The Craft of Text Editing: Emacs for the Modern World. This book surveys many of the specific problems that have to be dealt with in writing a text editor along with approaches, strategies, and algorithms for solving them. Its content should be relevant and useful even if your editor isn't going to look much like Emacs at all.
Well what you want to see sounds more like a tutorial than an actual application (I think applications like Notepad++ will be a lot to dive into in the beginning). Since you don't mention any environment you want to program in, you could check out the QT Text Editor Demo. QT is a cross platform GUI Toolkit so you are not bound to a specific operating system but probably harder to setup then a Visual Studio environment in Windows.
For Windows only you might want to think about digging more into the .NET platform (e.g. C#) as suggested in this question. It doesn't help learning C++ but it makes GUI development a hell of a lot easier.
Get the vi.
There is a big lack of true editors like vi/vim ;)
I mean there is a plenty of editors like notepad/notepad++,
but few editors which have separate command/control mode.
So You could look at the vi sources to inspire yourself and introduce something revolutionary.
Notepad++ is an excellent open source editor written in C++.
Notepad++ for some definitions of "simple".
You may also check out Scintilla editing component.
JuffEd. It is written in C++, cross platform due to usage of Qt and QScintilla. Notepad++ uses also Scintilla text editor component, but its limited only to Windows platform.
What sort of text editor would you like to make?
First question is will this be GUI or Console based?
GUI based, do you want to make something like Notepad? And on what platform? If it's MS Windows based, might I recommend picking up on MFC?
If it's text based, there are many open source solutions you can get into. My recommendation is to look at the simplest of editors like ed or something.
loot to the QT this is cross platform,HAVE RICHTEXT COMPONENT(widget).Writing first app in QT will give you actual knowledge.I recommend to learn QT by book