Window contentOrientation M1 error - qt

I have a QML Window which I want to assign contentOrientation property to Qt::LandscapeOrientation resulting in following line of code:
contentOrientation: "Qt::LandscapeOrientation"
Qt Creator shows me the following error in this code:
Invalid value for enum. (M1)
I am aware this is a very dumb error (I expect some downgrades :D), but how do I solve it?

In QML, the enums from the C++ Qt namespace area available in the Qt.X form:
contentOrientation: Qt.LandscapeOrientation
The documentation could be clearer about this, as it still says:
The default value is Qt::PrimaryOrientation.
I imagine that this is because the values are not documented in QML to avoid duplication, and this is the only way that they can be linked to.

Related

QFontMetrics Width using PySide6

I have the following line in my code:
self.textLength = self.fontMetrics().width(self.text())
It works with PyQt5, but I'm trying to move the code to PySide6, and when I do I get the error AttributeError: type object 'PySide6.QtGui.QFontMetrics' has no attribute 'width'
I've tried reading through the QFontMetrics docs, but everything I do seems to give the same error. Any ideas of how I can convert this line to PySide6? Thank you!
QFontMetrics.width() has been considered obsolete since Qt 5.5 and deprecated from Qt 5.11 (but will probably be still supported throughout any future releases of Qt 5), and eventually removed in Qt 6.
As the documentation (which already is in the obsolete members page of Qt5) reports, the results of width() were inconsistent and unreliable in many situations, mostly because it didn't consider the letter bearings.
You should use horizontalAdvance() or boundingRect().width().

Lyx: "Undefined control sequence" when using "preccurlyeq"

When I try using \preccurlyeq in math in lyx, and then compile I get error: Undefined control sequence
How can I fix that?
Go do Document > Settings > Math Options and then make sure "amssymb" is set to "Load automatically". If that doesn't work, change it to "Load always".
In the future (and also here if the above does not work), please always post a .lyx minimal example. For more information, read this: https://wiki.lyx.org/FAQ/MinimalExample

Qt Creator - Not Getting Function Argument Hints For Some OpenCV Constructors

I'm working with OpenCV in Qt Creator and everything is running fine. There is just this one problem that I don;t get function argument hints for some OpenCV constructors like cv::Size() and cv::Point(). I do however get argument hints for all functions of OpenCV. is there something that can be done about this? I do get argument hints for these in Visual Studio though.
In some versions of QtCreator the autocompletion does not work with typedef type objects. This bug was reported time ago, but I am not sure that it has been fixed (at least, it doesn't work for me in v3.1.0). Point, Size and Rect are examples of typedef variables (they are typedefs from Point_<int>, Size_<int> and Rect_<int> respectively) with which autocompletion does not work.
If at anytime you forget the constructor parameters, what I do is writing any of the template names (Point_, Rect_ or Size_) and QtCreator will autocomplete :)

Inheriting forms in Qt with CMake (multiple inheritance method)

I imagine this is fairly straight-forward, but I admit I'm not well-versed in CMake (or Qt for that matter), so here's the problem:
I have a form that was built in Qt Designer (with a .ui file). Two classes have been created that are based on this form. Both classes have a lot of duplicated code. So, I wanted to create a base class that inherited the formname.ui file using the multiple inheritance method to manage that common code.
The problem is that I don't know how to get CMake to build it correctly. Compiling gives me the error ui_formname.h: No such file or directory.
I've identified the following elements as necessary to get CMake to buld this correctly:
set (UI_HDR ${CMAKE_SOURCE_DIR}/path/to/formname.ui)
QT4_WRAP_UI (COMPONENT_UI_HDR ${UI_HDR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}) #Necessary here?
The difference between this and the other two cases is that this cmakefile is not building an executable, whereas in the other two cases, it was. It may be I'm missing something else, but the lack of an add_executable line is the most obvious difference that I can see, as the COMPONENT_UI_HDR variable would be included in that list, were it there.
Any suggestions on how to work around that?
Solved the problem. Indeed, I was right about the "add_executable" difference. Since this was a library and not an executable, I had to add a reference to the wrapped variable in the add_library call, i.e.:
add_library ( ${...} ${COMPONENT_UI_HDR} )
Compiled without a hitch...

Qt: Different tableWidget member names on workstations

I am using Qt on two ubuntu machines and am copying the source code from time to time between them. I found a really annoying problem when doing that and I can't figure out why this happens.I am using a table Widget to display some data and want to stretch the horizontal header to fit the content length. To do that I use the following line:
ui->tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
This works just fine.
I have a few of this codelines.
However, when I now copy over my source code to the other PC to work on it, I get the following compile error:
'class QHeaderView' has no member named 'setResizeMode'
Renaming 'setResizeMode' to 'setSectionResizeMode' will work just fine to fix that problem, but if I now copy the source code back to the first PC, it tells me:
'class QHeaderView' has no member named 'setSectionResizeMode'
...and I have to rename it to 'setResizeMode' again, to continue working.
I checked the Qt version on both PCs and they are both "Qt Creator 2.7.0" based on "Qt 5.0.1 (32 bit)".
Also the systems are up to date.
The only difference is, that I am using one of them in english system language, the other one in german...but I don't see how that would affect Qt's member declaration. o.O
Anyone knows what the problem is?
The constant renaming can get annoying over time.
it may be that the QT header versions don't match up
double check the QT_VERSION_STR in QtCore/qglobal.h
for a quick check if you are too lazy add a #pragma message("QT version: " QT_VERSION_STR) to the code to have the compiler output it while compiling

Resources