How to use QOverload "directly" ?
-
The attached code fails in C11 .
I am supposedly be able to use QOverload directly.
I cannot find an example of such syntax.Could somebody rewrite the attached code to do so ?
Or a link to "tutorial" ?connect(list_widget_1, &QListWidget::itemClicked, list_widget_2, QOverload<QListWidgetItem*>::of(&QListWidget::addItem));
-
@AnneRanch said in How to use QOverload "directly" ?:
The attached code fails in C11 .
Your usage of QOverload looks correct. This code compiles with no problems for me, on MinGW 7.3.0 32-bit and MSVC 2019 32-bit:
auto list_widget_1 = new QListWidget; auto list_widget_2 = new QListWidget; connect(list_widget_1, &QListWidget::itemClicked, list_widget_2, QOverload<QListWidgetItem*>::of(&QListWidget::addItem));
So, your issue is not in the syntax, but somewhere else.
Please post the error message that you received and the section of your code that initializes
list_widget_1
andlist_widget_2
. Please also provide your version of Qt and your compiler. -
Already asked here: https://forum.qt.io/topic/121355 - you need to use a proper compiler which understand c++11.