Should I use Qt Widgets or Qt Quick to develop a rich text editor? - qt

I am new to Qt in general, and I have been playing with it to get to learn about it since I have to develop a very specific text editor.
I want to know if anyone could help me understand which one is better (or the most indicated) for the development of a rich text editor. I have worked before with C and C++ but Qt Widgets seems like a very step hill for the time being and I am completely new to javascript in general.
Some of the settings that I would need to implement on the text editor for better context are:
Look for the user to be always connected to internet.
Transfer and receive data from another program.
Grant read only to the opened files and then permission to write on them when a button is clicked.
Has to work on linux and windows.
Needs to look great.
My context:
So far I have done a few little applications and even a little rich text editor on Qt Widgets, but since I was having problems with the GUI implementation that I wanted, I started looking for a way to solve it and found that Qt Quick might be the solution.
I have been trying Qt Quick, and for now on looks great, but I do not know if it has the capabilities to do what I have explained before. Or if it is better to use one or another.
I decided to create a new post since the one that I found looking for something similar is from 2014.
Also, the text editor for now only needs to work on desktop, but in a future might be on other devices and embedded systems.

Related

Is there a way to generate windows and/or components in Ignition?

I was hoping that Ignition had a way to import/export windows to a non-binary format such as JSON or XML, but that seems not to be the case (or is there a way?).
Is there a way to use the script console to generate and populate a new window, or to insert components into an existing window?
This would be used for inserting templates and other components, such as navigation buttons etc.
Yes, but...
I assume here that you're referring to Vision windows. The windows are indeed binary serialized, but the underlying structure is XML. But getting the deserialization done programmatically is a pain and probably not worth it.
You can get a feel for what this looks like by opening a Vision window in the designer, right-clicking its Root Container and choosing Copy, then pasting it into Notepad. I myself tried to find a way to do this from a module and decided it wasn't worth it. For more detail, you can view that thread in the Ignition forum here.
However, that's not really useful for generating and populating a new window.
To do that, you need to do some Java programming. Vision is Java Swing under the hood. There are a couple ways you can dynamically build / populate a Window.
From Python, you can import any Java libraries you need and generate the window dynamically. For relatively simple things, you're probably better off working with the Template Canvas component. There's an Ignition forum thread discussing this topic here. This would be more of a run-time generation, not from the Script Console.
You can write your own module to do it.
Module SDK Vision Component Guide
Vision Component Module Example
Good luck!

Create Qpushbutton,Qlabel or else with code

In Qt i don't want to create button,label or else in design like drag and drop, but i want to create them with using code, so anyone can share the tutorial links for me about this code lessons please ?? sorry in advance for my bad question
I loved these video tutorials. Covers an awesome introduction into basic stuff, but a lot of advanced topics, too. I realize that your question includes a pyqt tag. Qt is really easy to handle with C++ though, especially for basic GUI programming. So if you don't absolutely have to use Python this is really worth getting into. On top of that, the python and C++ interface for programming Qt have a lot in common. So in any case it would not be a waste of time. Next time, take 5 minutes and search the web a little. There are tons of awesome tutorials out there, that are just a few key presses away using the search engine of your trust.

Can I edit form1.ui.h outside of qt editor?

The Title says everything. I'm pretty new to qt and don't really like the editor it provides.
vim form1.ui.h doesn't work.
Most likely you mean header file generated from your .ui file. Well, since it's generated - editing it is not very good idea, because it will be regenerated from .ui each time you build you program.
But you obviously can:
Edit .ui file with any xml/text editor. Though it's really strange and wouldn't win much over using designer itself.
Do not use .ui files at all - encapsulate creation of desired interfaces in your own classes containing simple C++/Qt code. That way actually is not that bad if you're experienced with Qt layout/widget system and know what you wish to achieve. Because there's no any kind of pixel hunting needs to be done in designer and placing things in appropriate way may actually be done even in more structured manner in code than in form creation. Though as I said it's not the way for everyone and you have to be accurate, also it's better separate interface code from other functionality.

Qt Designer vs Handcoding

Every time I start a project with some graphical toolkit, one of the first conflicts happen with the decision of how to deal with the visual design and the widget layout: A graphical tool or handcoding?
This is a quite tricky/subjective question because most people will decide based on personal preference. It also depends greatly on the quality of the graphical tool. In this case I would like to focus just on the latest version of the QT library. I do not intend to discuss which method is better. I am convinced that the best answer is: depends on the project.
What I want is a reference to a good non biased article, based on experience after several projects. The article should just describe the tradeoffs of both choices
I started with doing everything hand-coded, and of late have been switching to using Qt Designer for most forms. Here are some benefits for each position:
Using Qt Designer
The biggest time saver for me is managing complex layouts; it saves a lot of tedious coding. Simply (very roughly) arrange your widgets, select them, right-click, and put them in the correct type of layout. Especially as layouts become nested, this is so much easier.
It tends to keep your implementation files cleaner instead of filling them with all the boilerplate layout code. I'm type-A, so I like that.
If you are translating your application, it is possible to send your translators the .ui files so they can see on your GUI where the text they are translating will be. (Assuming they are using Qt Linguist.)
Hand-coding
Control. If you have a layout where you need to instantiate / initialize the controls in a very particular order, or dynamically create the controls based on other criteria (database lookup, etc.), this is the easiest way.
If you have custom widgets, you can kind-of-sort-of use the Designer, adding the closest built-in QWidget from which your class derived and then "upgrading" it. But you won't see a preview of your widget unless you make it a designer plugin in a separate project, which is way too much work for most use cases.
If you have custom widgets that take parameters in their constructor beyond the optional QWidget parent, Designer can't handle it. You have no choice but to add that control manually.
Miscellaneous
I don't use the auto-connect SLOTS and SIGNALS feature (based on naming convention such as "on_my_button_clicked".) I have found that I almost invariably have to set up this connection at a determinate time, not whenever Qt does it for me.
For QWizard forms, I have found that I need to use a different UI file for each page. You can do it all in one, but it becomes very awkward to communicate between pages in any kind of custom way.
In summary, I start with Qt Designer and let it take me as far as it can, then hand-code it from there. That's one nice thing about what Qt Designer generates--it is just another class that becomes a member of your class, and you can access it and manipulate it as you need.
My answer is based on two years developing biochemistry applications using PyQt4 (Python bindings to Qt 4) and OpenGL. I have not done C++ Qt, because we only used C++ for performance-critical algorithms. That said, the PyQt4 API greatly resembles Qt4, so much here still applies.
Qt Designer
Good
Exploration. Discover what widgets are available, the names for those widgets, what properties you can set for each, etc.
Enforces separation of UI logic from application logic.
Bad
If you need to add or remove widgets at run-time, you have to have that logic in code. I think it's a bad idea to put your UI logic in two places.
Making changes to nested layouts. When a layout has no widgets in it, it collapses, and it can be really hard to drag and drop a widget in to the location you want.
Hand coding
Good
Fast if you are very familiar with Qt.
Best choice if you need to add or remove widgets at run-time.
Easier than Qt Designer if you have your own custom widgets.
With discipline, you can still separate UI layout from behavior. Just put your code to create and layout widgets in one place, and your code to set signals and slots in another place.
Bad
Slow if you are new to Qt.
Does not enforce separation of layout from behavior.
Tips
Don't just jump into creating your windows. Start by quickly sketching several possible designs, either on paper or using a tool like Balsamiq Mockups. Though you could do this in Qt Designer, I think it is too tempting to spend a lot of time trying to get your windows to look just right before you've even decided if it is the best design.
If you use Qt Designer for PyQt, you have the extra step of running pyuic4 to compile your *.ui files to Python source files. I found it easy to forget this step and scratch my head for a second why my changes didn't work.
If you code your UI by hand, I suggest putting your layout code in one place and your signals and slots in another place. Doing this makes it easier to change the way your widgets are arranged on a window without affecting any of your application logic. Or you can change some behavior without having to wade through all the layout code.
Enjoy Qt! Now that I am using Java Swing for work, I miss it.
I tend to layout dialogs using the designer but I do all the event handling stuff in the main code. I also do all the main windows, toolbars, menus in direct code.
The designer is just frustrating - a pity since decent drag and drop sizer based designers have been around for more than a decade
It depends on the number of different windows/panels you need for your application. If the number is small, use a graphical tool. It is much faster to get a few windows designed perfectly. If the number is large, the graphical tool can (and should) only be used for prototypes. You need to code the layout to be able to make application-wide changes at acceptable cost.
That includes creating a model of how the UI of the application works and dynamically adding and removing widgets at runtime. For an excellent example of such a model (in a different environment), take a look at the glamour model for creating object browsers.
I object to the suggestion that it is tricky/subjective (at least more than other development choices). It is easy to come up with criteria to decide on. Personal experience and preference are important for that, as they decide when the number of different windows should be considered small. The same goes for tool quality.
My personal opinion (just personal), all GUI based development distracts me too much, my imagination or my mind works very bad when i'm seeing gui objects, i prefer to hand-coding most the time because my imagination works better, you know, is like you were reading a book with no images... when i see nothing else than code its looks like i finish faster...
Second reason, i like c++ so much, so I see the good side of hand-coding, is that I keep my c++ practice no matter if I'm writing something redundant... Coding skill is improved when you only use text... Indeed, i could use nano or vim, but that is too far slow for debuging.
Hand-coding here ++vote
I use a combination of both:
I find for x,y coordinates, Designer is the way to go.
A lot of the other UI properties etc can be set in your code.
I think trying to do UI completely by hand-coding would be a very time consuming project. It's not as simple as setting up HTML tables.
Yes version 4 is bad, but people at work who have used version 3 said it was REALLY bad. Lots of crashing.
I, along with my fellow QTers, are truly hoping that version 5 will be an improvement.
I know this is an old question, but I hope this helps! One man's experience.

flashdevelop vs flex builder

I just started making games and I decided for my next project to use either flashdevelop or flex builder. Reason being is because you can embed just about everything and for licensing purposes and it recommended the the game is compiled into one file. flex sdk is good with that type of stuff.
As of right now I decided to use flashdevelop. but recently it's been kicking my behind. First I wasnt able to use ui class (e.i. buttons, and textboxes) probably because of something stupid I did. Now for some reason I can not compile my applications. When I compile, nothing happens, no errors, no nothing. below is a screenshot of what happens when I compile.
Yes i installed debugger and yes I installed sdk
So now I was thinking about just going with flex builder. Not sure which one is more easier to assemble and use. But I do know the flex builder community is bigger, and they have a much better documentation. I am good with actionscript, but I am not so good with using flex.
My ultimate question is...
Which one is easier to assemble
which one is easier to use
which one is BETTER overall
as far as not compiling goes, looks like it compiled just fine.
I don't know what you're expecting to see from the code other than the "Hello"
to see that open up your output window (under View)
Whether you use flex or flashdevelop, you end up using the same compiler.
Like Adam, I find flashdevelop easier to use than flex, but that's because I've used it more (flex trial expired and FD didn't)
And plus I'm fast with FD, like really fast :)
Try some of the shortcuts:
to create getter and setter or
generate function press 'ctrl shift ~' and PRESTO
or for a for loop or for each loop type in the first few
letters and press 'ctrl B'
to find instances of any string in code you
can do F3 and shift F3, whereas F4
will find the object or function
declaration(even in separate files)
FD also adds a lot of the classes as
needed (sometimes I have to do it manually)
and the latest version lets
you generate classes which extend
another class easier.
I'm sure that flax does most of this as-well, but when you're already used to this then switching slows you down.
I had the same issues when I started working with FD. What it boils down to is that flex has a bunch of libraries that it's using that FD doesn't unless you link to them, and sometimes even then.
But once you start compiling your libraries and assets into SWCs you will be able to compile them through Flash and Flex. Which can be handy (like when you're working with other developers)
FD doesn't have a profiler, but this has not prompted me to stop using it. When I need some debugging and trace isn't enough I add the demonsters debugger class: http://www.monsterdebugger.com/ it's pretty powerful, but you still can't step through your code.
** Update - Flash Develop has had a profiler for a few versions now, It's good for watching memory use, but I still end up using monster debugger a lot. You can use debug in Flash Develop as-well and step through your code.**
FD doesn't have the UI that flex does, and for developing mxml it is a bit more tedious, but at pure as3, I find FD is all I need. Well than and Flash to create my SWCs
I think a lot of it is personal preference, and what you have previously used. Some people do have strong opinions though.
Personally I like FlashDevelop, but only because I am use to it, and can get things done a lot faster e.g. setting up projects, workflow, shortcuts etc. But I am sure If I forced myself to only use FlashBuilder (formally FlexBuilder) that I would soon come to grips with its nuances.
Here are a few of my points for either side:
FlashDevelop:
I like how FlashDevelop is so simple,
where as Flash Builder is rather
bulky.
FlashDevelop is totally free, where Flash Builder actually cost quite a bit.
Flash Builder:
Built on Eclipse, so has a massive community, tons of plug-ins etc.
Source control intergrated into the IDE (very important in large projects).
Also might want to check out this article on ActionScript Editors.
I know it's an old topic, but in case someone finds it, here is an interesting thing I've noticed:
I am using pixel fonts in my project, and by default Flash Player blurs part of it (it is a known problem). One solution is to use a bitmap text (some kind of custom class) and the other is to use Text Renderer with some of its related elements to force Flash to render the font correctly. When compiling under the same version of Flex SDK in Flash Builder 4+ the font rendered correctly. But when I compiled with Flash Develop (latest version) the text was really ugly, with missing pixels at random places. It might be caused by the fact that Flash Develop or Flash Builder are sending some hidden arguments to the compiler which either make it work/break.
This is a long running question that has been repeated a few times. Review this question and see if it answers yours.
Web-based Game Development: Flex Builder or Flash CS3?

Resources