QLCDNumber in Qt - qt

I'm using a QLCDNumber in Qt and when the number changes the previous number does not get cleared so I eventually end up with 888 and the changing values can not be seen. Is there anything I need to do to clear the previous value? Thanks

Using Qt 5.2 and Qt Creator 3.0 on Windows 7 works perfectly for me (and should for you too). You can start from a basic example and build on top of it:
Create a default Qt Widget project;
Add a QSpinBox and a QLCDNumber;
Connect the QSpingBox valueChanged signal to QLCDNumber display slot.

Related

Signal for tag change

I can't find the correct signal to connect to after changing or adding tags.
The signals I want is when you run these commands:
tag:view_only()
awful.tag.viewtoggle(tag)
It is property::selected. In the newer doc (for what is going to be version 4.4 eventually), you can press on Click to display more on properties to see info about signals.

Workaround Qt bug Combobox dropdown appear behind window

Right now I have a small tool app that runs in the icon tray. When I click on the icon, the app goes into "windowstayontophint" mode. I added a Combo Box on this window. But when I click elsewhere on desktop, and then click the combo box, the drop down window goes to the back of the window. This seems to be a known bug as reported here:
https://bugreports.qt.io/browse/QTBUG-61804
Is there a workaround for this? I am using Qt 5.9.1.
EDIT: Add some code:
This in MainWindow constructor:
Qt::WindowFlags flags = this->windowFlags();
this->setWindowFlags(flags|Qt::WindowStaysOnTopHint);
Then I put a QComboBox in the mainwindow with preloaded items. First time click, the dropdown appears on top as normal. Then I click onn desktop and then back on the mainwindow and combobox. And drop down becomes at the back of mainwindow. CLick on the link above to see what I mean. The bug report also provide screenshot of what is happening.
Nobody want to put an answer, so I answer this myself.
ANSWER: Update to latest Qt.
It did not work for me because I was having trouble updating (noob here). What basically happened was that Selecting "Update" option on Maintenance Tool does not update SDK from 5.9.1 to 5.10.1. It only update certain things like Qt Creator.
I needed to choose "Add or remove Components" and then adding Qt 5.10.1, but only check the MinGW 32bit only. (Uncheck all others otherwise you need them (like android or other)).
Even after that, you also need to manually download CMake (get it from cmake.com) and set it in "Manage Kits" in Qt Creator.

A way to connect checkbox state to widget visibility in Qt Designer

Does anyone know if there is a way to connect a state of a checkbox in Qt to an object visibility in Qt Designer? I somewhat new to Qt and and prefer to work with Qt Designer rather than messing with the UI code manually. Qt version I'm using is 4.8.6
Any help is appreciated.
In code (old Qt 4 way):
connect(checkbox, SIGNAL(toggled(bool)), widget, SLOT(setVisible(bool)));
or (recommended Qt 5 way):
connect(checkbox, QCheckBox::toggled, widget, YourWidgetType::setVisible);
In Designer: open the Signals And Slots Editor, connect signal and slot above.
Noticed that signals and slots from Designer are reset sometimes, don't know why. Maybe it is more reliable to connect them in code on widgets setup.
Yes, you can connect the checkbox's toggled(bool) signal to the widget's setVisible(bool) or setHidden(bool) slot in Qt Designer - either in "Edit Signals/Slots" mode using drag-and-drop, or in the "Signal/Slot Editor" dock.
If using the drag-and-drop interface to add the connection, you'll need to turn on "Show signals and slots inherited from QWidget", else setVisible(bool) and setHidden(bool) will not be available for the target widget.

error dialog box with Qt quick

i'm programming a Qt Quick application and I'm looking for a possibility to display the user errors. In Qt widgets there is QMessageBox but i can not find any equivalent to this in Qt Quick.
Sure i can create a MessageBox by myself but I can't imagine that there is no given possibility?
I found an ebook on the official site here and there is an Dialog described on page 67 but it doesn't work anymore and i can't find any further information about that. Is it dropped in the current version?
Thanks in advance
There is no Qt-Quick component for this yet. What I do in my application is using the Window QML component. I set the modality property to Qt.WindowModal to have it as a modal Window. You can then use the Button component to create OK/Cancel buttons.
Another thing I do is create these modals dynamically when something wrong occurs using Qt.createComponent() in QML.
Edit: Just discovered a new Dialog component that will be released in Qt5.2 that seems to match what you are looking for: MessageDialog

Fails to paint within QGLWidget

I have a weird issue with OpenGL in Qt. I have a derived class from QGLWidget. I use makeCurrent() in initializeGL because I need to call some OpenGL functions first. The OpenGL widget is embedded into a QFrame.
When I run the application in QtCreator, it perfectly runs. When I run it as a standalone one, the OpenGL surface seems not to update at all.
Any clue?
EDIT: the problem seems to come with optirun…

Resources