Help Qt Widgets for creating Accessories Bar on my device - qt

For a handheld device I want to put a vertical Bar which will contain widgets that show the battery status of device, network connectivity status, Date and Time etc. For this Bar I have chosen a GroupBox and for the widgets inside that (lets say batter status) I am planning to use QPushButton. Is it correct I am doing or there is some special widgets for this purpose?
Please suggest.

That would work, but is it the best answer? That really depends on you UI design. Qt's widgets are extremely flexible and there are many ways to do any one function. Couple of points -
If you don't need header over area, then you don't need group box, then you can use a plain widget or a frame as a container.
Many objects can display graphics, so pick them for underlying functionality and make code simpler.
All widgets can be highly customized to fit your specific needs.
Hope this helps.

Related

How can I use QMenuBar to switch between widgets?

I don't know much about QT. I am trying to do my first GUI and actually this is the first thing that I want to do.
How can I set up top menu bar to switch between layouts? Again, I don't know yet how to even set up these layouts and I don't know the jargon to name the things theirs names, but I'll get to it.. I hope.
Actually, Windows has this type of windows all over the system. Can I make one of these myself?
Qt has a QtabWidget that has its own layout on every tab, so you dont need to define anything, qt handle t runtime the display of the layout associated to every tab

Best Qt Widget to use for flow controls

I want a widget that can have various number of input & output pins, and each instance of this widget acts as a module which can connect to another module via these pins. Eventually, this will give me a work flow with many connected blocks. Ideally, the connection can be done via mouse operations such as drag and drop from one pin to another. And I also need to add texts or even draw some shapes onto the blocks.
I know that I can write this from scratch but what's the best base widget to start with?
I would go with QGraphicsItem. It supports features like drag & drop, collision detection, etc.. Those should be useful for your use-case. Make sure to check other classes that inherits this one (look for Inherited By:).
Also, make sure to check out this article.

Zooming a view in PyQt?

I have a simple to do tree application that displays a QTreeView inside of a QMainWindow. I want to give the user the ability to change the magnification level of the content (using a spinbox most likely), but without actually changing the underlying font size of the text.
Is there a way to do this without changing my whole app to a QGraphicsScene? The app is just showing a good-old fashioned tree with text, no graphics or anything fancy other than wanting to change the magnification of the view; hence, I am thinking that switching to a graphics scene would be overkill.
Or, am I wrong, and switching to a graphics scene is the only simple way to do it?
Note a trimmed down version of the app is at Code Review. It contains a SSCCE, but is a bit long to post here.
In a site discussing how to put widgets on a scene, trolltech wrote (emphasis added):
I myself and several other Trolls’ve spent some time researching this
topic [how to embed a widget in a QGraphicsScene]. It’s not trivial;
most solutions to embedding widgets into a scene end up with several
serious drawbacks. That’s also why Qt doesn’t have any off-the-shelf
solution to this.
Widgets cannot be scaled or rotated, but graphics items can.
This suggests I cannot perform, in a simple way, the operations I want to on my QWidget by itself. That is, perhaps I need to add it to a scene, which is what I was trying to avoid. If that is the answer, then I'll accept it and start a new question if I get stuck doing that.
Note I just found this question, which is pretty much a duplicate, and does not have an (accepted) answer.
Related content
http://www.qtcentre.org/threads/62745-Zoom-a-view
QTableView Zoom In/Out
Drawing widgets (such as buttons) over QGraphicsView
QGraphicsView Zooming in and out under mouse position using mouse wheel
https://forum.qt.io/topic/15308/qgraphicsview-zooming-with-qslider
https://wiki.qt.io/Smooth_Zoom_In_QGraphicsView
As suggested by the docs quoted from trolltech in the original question, there is no built-in method to zoom on a view.
If the goal is to avoid the use of QGraphicsViews, the simplest way to separate the size of the font on the screen, versus the size of the font saved or printed, is to basically have two fonts. One to be displayed on the screen you can call 'zoom', versus the other to be saved/printed and call that 'font size'.
I got this idea from qtcentre (in a post I added to the original post too):
http://www.qtcentre.org/threads/62745-Zoom-a-view

Create drag-able panels in Flex like its in netvibes.com

I want to create a news application for my website.
My question is how should i create drag-able panels/canvas inside another panel/canvas.
What i exactly intend to do can be seen on netvibes.com . The website has different panels of every news group, and this panel could be moved from one place to other, but in a well defined manner. And the other panel take over the place of dragged panel.
Is there any component in flex, which can help me make something like that.
If i was unable to make my question clear, plz let me know, i will try to make it more clear.
Regards
Zeeshan
A TileList with drag and drop enabled should be able to accomplish something like that. Or, use a Spark List with a custom layout that you create.
It might be a bit tricky getting the list elements to drag and drop based on clicking the title, but it should be doable.
I think you should consider a more advanced solution with drap-n-drop with a custom panel based component. The places the panels can move can be implemented with a different custom canvas based component. The advantage would be to move the components into different custom positions and panels can be resized independent of each other.
Adobe has some good tutorials for drag-drop operations.

Customizing QDialog layout at runtime

I have Qt dialogs which need to adjust for a different locale at runtime.
The locale is set once at program startup and doesn't change.
I need to change both the label text and the ORDER of some text input boxes.
eg. Text boxes are day,month,year or month,day,year.
Is there a common/simple way to do this?
(note - it's not a simple date control, it's a complex industry specific thing. The date is just an example.)
If you are looking for a full automatic way to handle this, it would be too complicated because of a lot of scenarios and requirements.
A simple and intuitive way is to use QStackedWidget and put different layout on separate stacks, activate one stack according to locale at runtime. But how to handle the events or acquire data? embeded UI may help.

Resources