C++ & Qt : A slider like in Adobe After Effects - c++

I'm quite new to C++ & Qt, but I would like to implement sliders like in After Effects in an opensource project i'm working on.
I mean, not a "visual" slider (a bar, like at the left of the pic), but
a numeric value, which is shown like an hyperlink;
and which change if you click & slide right or left.
You can either slide on it or click it and directly enter the value.
(source: pencil2d.org)
Any ideas ?

I'm no expert either, but this may help you.
It sounds like you want to create your own widget.
Then you should subclass QWidget, reimplement mouseEvents (to make it respond to vertical "drags") and paintEvents(to make it look the way you want it to look), give it the signals you need. If you don't want to start from scratch, maybe sublcassing QLineEdit you gain some steps. Look this trhead, and this tutorial. This last is a real "eye opener", if you take the time to understand it thoroughly. Good luck!

Related

Qt - What should I use to implement multiple windows?

I've started learning Qt (C++) and I'm overwhelmed by the whole lot of component it has. I'm writing my first application and here's what it should look like:
When I run it, I have one main widget which has 8 QPushButtons.
When I click any of the buttons a 'window' should open and it should
contain about 25-40 various labels, buttons, checkboxes, radio
buttons and so on. So, I need 8 'windows'.
My question is: what should I use to implement these 'windows' - Widgets, Dialogs, MainWindows? What is like a conventional QT way of solving this problem?
It depends on how you want your application to look like.
If you want to have multible 'Windows' like different Tabs in your application then use QStackedWidget Class or QTabWidget Class.
If you need something like a Pop-Up you could use a QDialog.
Please make sure you understand how QWidget works and always take a look in the Qt Documentation.

Qt QCombobox popup inconsistent position

I have searched far and wide and cannot find anything online about my issue even though it seems rather trivial, and i feel like there's just something I'm missing, so I apologise if the answer is apparent.
However, when I use a QComboBox in Qt, When I click on it instead of dropping down like I want it to, it shows the popup with the current selected item as the origin. If that doesn't make sense this is what I am referring to:
It shows the popup starting at the current selected item where the button is. I just want it to drop downwards like any other normal combobox! How can i Achieve this? If i make it editable it drops down exactly how i want it, but i don't want it to be editable!
Does anyone know what's up?
Edit:
I am running Windows 10

Hide Page/Tab from QTWidget - QT 5.5

i need to hide tabs from a existing project in QT, i don't want to delete the code because i have to set parameters on that code, the Application relay on that too. Seems like QT hasn't built-in hide(); function, i tried to edit stylesheet to make it smaller, but doesn't work too, i've looked on the internet and seems like this is a known issue. Does somebody have some tricks to avoid this?
Only thing i was able to come up with is:
ui->TabObject->setEnabled(false);
basically i disable objects in the tab to make them not usable by the user, but this is not a good thing for the whole UI.
Maybe by calling QTabWidget::removeTab(index) - this removes the tab from the QTabWidget, but does not delete the tab's QWidget.

Customizing CMFCRibbonBar im MFC

I am trying to customize the default MFC RibbonBar. I need to reduce its height, change its color etc, but so far i haven't found anything on how to do so. I've been to msdn, and they just tell you how to add new controls on the ribbon.Can any one please point me in the right direction? Is this ribbon control even customize-able? i mean apart from adding categories and other controls on it, i want to change the look of the ribbon.
Some code samples about how to work with MFCRibbonControl would be of great help too.

Making a game in Qt regarding GUI windows

I've been wanting to program a simple game with a simple GUI using Qt (Its will be a VERY simple game, nothing fancy). What I've been wondering is, how can I create multiple windows and display them when needed? For an example, a battle screen and an inventory screen. The user should only see one of them, but should be able to access the other one when needed. I was using stacked widget but I'm not sure if that's the proper way. Also, is it better to design the windows in the designer or to code them?
A StackWidget certainly would accomplish what you want to do. The reason why it is not always used for this kind of thing, is that it all the screens are pre-created at the beginning and always exist. This means it takes a little longer to initialize, and you are using more resources than you need at any one time
But as you are saying, if this is a simple game, then I don't see a big problem with it. Just as easily, you could also, create an empty layout and swap the inventory and game panels as needed.
Add my vote to everyone else suggesting to use the designer. It is so much easier to manipulate layouts, actions, and such using the designer then through code.
You can see the Designer manual here
So this is what I would suggest:
Create your "battleScreen.ui" - which is the designer file for your battle screen and everything in it, and then create your "inventory.ui". Both of these could be QWidgets, or QFrames, or whatever makes sense.
Then create your "Game.ui" which will be your QMainWindow.
In your Game main window, you can then add your QStackWidget, and place your inventory, and battle screens in the stack widget.
If you don't know how to do that...
1) drag a QWidget into your form (into the stack widget)
2) select the new QWidget and right-click.
3) Select "Promote to..."
4) Fill out the information to promote the QWidget to your inventory class
Promoted Class Name: The name of your inventory class
Header File: The header file of your inventory class
5) Click add
6) Click Promote.
Hope that helps.
Since I'm not sure what your goals are I can't advise whether or not the stacked widget is appropriate but I think you can accomplish quite a lot using the designer and style sheets. If you need to code some parts of the GUI, you can always drop in a place holder widget and either replace it with coded items or make them children of the place holders.
A general answer for a general question:
Use the Designer to create your windows; hide and show the auxiliary windows as needed.
Use a flow manager class to manage the visibility of a related set of windows.
The stacked widget is useful for managing a button/icon whose appearance changes based on state; the different representations live in the stack.