I'm working on a simple board game in qt, and i have some problem with the layout. I have two players, their health is represented with pixmaps, at the bottom of the screen. It looks now something like this:
Notice, that i would like to keep the health indicators on the opposite sides of the screen, and the button in the middle centered, relative to the screen.
BUT when some of the players loose health, this happens:
If the drawing were not understandable, here, i took some screens:
So the problem is, that the button in the middle starts shifting to one of the edges of the sreen because of the spacers. I understand why it does it, but i simply can't find a solution.
Please if you have any ideas, how i could make this layout work, help me!
Thanks in advance!
Make an empty (fully transparent) health indicator pixmap which has the same size as the heart pixmap. Then you can always place three same size health indicator pixmaps for both players.
You can put a Widget where your health indicator should be, set its sizePolicy to a fixed size, and put your health indicator pixmap inside that widget.
Related
I am working on a project with Qt 3D Studio, I have a concern regarding animating single objects in slide, while rest of the objects are not effected.
To explain, let's consider three Slides "MoveCarRight", "MoveCarCenter" and "SignNoRight". (Please see attached picture to give you idea about my scene.)
"MoveCarRight" is used for moving car to right, "SignNoRight" is used for animating traffic sign on the Z axis so that it enters the scene.
I control those slides from QML side by entering:
presentation.goToSlide("Scene","MoveCarRight")
presentation.goToSlide("Scene","SignNoRight")
However, inevitably I can't control the objects seperately. When I go to slide "SignNoRight", I want the car to stay the same, if it was previously moved to center, it should stay at the center, if it was previously moved to right, it should stay right. Right now, when I enter "SignNoRight" it is always centered.
I would think there would be a simple solution to this, yet I couldn't find it. Any help is greately appreciated. Thanks in advance.
I have solved my problem with the introduction of data input controllers. See example: https://doc.qt.io/qt3dstudio/openglruntime/qtstudio3d-qmldatainput-qml-qmldatainput-main-qml.html
I am currently building a minesweeper game which has three different game modes. Harder mode has more objects and a bigger window size. When I try to switch back to a simpler mode, the size of the window will not resize to a smaller window, which will make the layout look terrible.
Before it looks like this:
After switching from a harder mode, the layout will be like this(which remains the size of the harder mode):
So what can I do to set those windows to suitable sizes? Or what can I do to set a default window size for each mode? Thanks
There is a few things you should look into:
Size policies. Size policies of the individual widgets dictate how they might shrink or be expanded vertically and horizontally. With the right policies, elements like the icons and scores at the bottom will stay reasonably sized in all geometric configurations. Depending on how you realized the playing field, you can also use size policies there to ensure that elements don't grow too big.
Spacers. A horizontal spacer element in the middle of your bottom bar will help keeping the icons and scores small and in position. It will eat up the additional space.
QWidget's adjustSize() method. You can call it whenever your playing field changes. If your playing field does not work with size hints, but absolute sizes, you can call resize() on the playing field widget, and then. if necessary, adjustSize() on the main window.
first of all I am not the big front end developer, but I know at least normal CSS design methods. My problem is, I want one image, lets say a worldmap.
On the map I want pins and when someone hovers over that pin a info box will be shown. Thats no problem, when I use CSS circles with a hover effect and a little bit of Javascript. The problem is that the trick with the position of the circles only works, if the size of the image stays the same. When I have a responsive image, the pins are somewhere else.
Thanks!
I have been using awesome in on ubuntu 14.04 for a while. The default layouts defined in rc.lua is:
layouts =
{
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral,
awful.layout.suit.spiral.dwindle,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier
}
I have a hard time to wrap my head around this! Some of them I managed to understand (I think) just by testing them out, but not all of them.
I have tried to find some documentation that describes it but with no success. Is there some documentation where I can read about them and the conceptual thoughts behind it all? When and how they are suitable for different tasks.
I understand that its individual but if there was some sort of information at all about these things the awesome community would benefit greatly form that I think!
I understand a visual documentation would be awesome, but afaik there is none. There is a (very superficial) text description here, though, which I'm transcribing (which some minor fixes) below:
awful.layout.suit.corner.nw
Corner layout. Display master client in a corner of the screen, and slaves in one column and one row around the master.
awful.layout.suit.corner.ne
Corner layout. Display master client in a corner of the screen, and slaves in one column and one row around the master.
awful.layout.suit.corner.sw
Corner layout. Display master client in a corner of the screen, and slaves in one column and one row around the master.
awful.layout.suit.corner.se
Corner layout. Display master client in a corner of the screen, and slaves in one column and one row around the master.
awful.layout.suit.floating
The floating layout.
awful.layout.suit.magnifier
The magnifier layout.
awful.layout.suit.max
Maximized layout.
awful.layout.suit.max.fullscreen
Fullscreen layout.
awful.layout.suit.spiral.dwindle
Dwindle layout.
awful.layout.suit.spiral
Spiral layout.
awful.layout.suit.tile.right
The main tile algo, on the right.
awful.layout.suit.tile.left
The main tile algo, on the left.
awful.layout.suit.tile.bottom
The main tile algo, on the bottom.
awful.layout.suit.tile.top
The main tile algo, on the top.
The documentation layouts details them.
Some issues can occur to understand what happened when you use these layouts when you "accidentally" press ModKey + Shift + h or ModKey + Ctrl + h. It modifies the tile view.
Try the layout with these modification to find the best layout for your needs.
I'm struggling with QMainWindow and QDockWidgets, it seems a messy area.
I need the very simple thing: when application is closed, the arrangement of dockwidgets should be saved, and when application is opened, the arrangement should be restored.
The problem is that saveState()/restoreState() methods deal very strangely with central widget. There are several variants, and each has its own problems:
1. Central widget is set to, say, QPlainTextEdit or QLabel
When state is restored, dockwidgets occupy as much horizontal space as possible, with thin central widget in the middle of left and right dockwidgets. Size and position of central widget is kept only vertically, but horizontal boundaries between dockwidgets and central widget is not saved.
2. Central widget is set to NULL
If I explicitly call:
this->setCentralWidget(NULL);
Then stateSave()/stateRestore() do work: state is saved and restored correctly, but for some strange reason user is unable to dock widgets at the top or bottom. Widgets can be docked only in one horizontal row, no matter how hard I try to dock it at the top or bottom.
3. No central widget
By "no central widget" I mean not touching central widget at all. For some reason, the behavior is different comparing to NULL central widget:
State is saved and restored correctly, but if I make my window small, and then expand it again, then dockwidgets will remain small with huge unused area in the middle. So, user will have to resize them manually.
All of this looks very strange. Probably I'll have to go with "no central widget" variant, but I'm confused because I don't understand the behavior, maybe it's a bug, and then, behavior may change in future versions.
So, each of these ways has its own problems. If anyone can give me some clue on solving any of them, I'd be very glad.