cplusplusqt | Unsorted

Telegram-канал cplusplusqt - C++ & Qt

1169

Link: @CplusplusQt Embedded: @EMBCpp • Allowed Topics: C++ and everything related to Qt • Use only English • No Private Message without asking user's permission • No NSFW • No Spam • No unauthorized Bots • No Offtopic • No Self Promotions

Subscribe to a channel

C++ & Qt

I need functionality of

nx.algorithms.has_path(g, node_addr1, node_addr2)

Читать полностью…

C++ & Qt

Another question what is the minimal condition for covariance? isnt it enough that class B inherits class A?

Читать полностью…

C++ & Qt

Perhaps you have to add some include directories? Perhaps the header file you included tries to include other files?

Читать полностью…

C++ & Qt

A good strategy is to focus on the first error. Solving that often makes the rest go away too.

Читать полностью…

C++ & Qt

Last few hours when I was getting error it was 100% clear what happened, now its just a pile of a mess

Читать полностью…

C++ & Qt

I meant a single .h file that I include into another .h causes the build error

Читать полностью…

C++ & Qt

Hellow everyone, can smbd give me a clue why when I include *.h im getting many build errors? Or the question is a bit silly cuz highly depends on the implementation?

Читать полностью…

C++ & Qt

from PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
import sys
import typing


class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict]) -> None:
super().__init__()
self._data = data

def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
if parent == QModelIndex():
return len(self._data)
return 0

def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> typing.Any:
if not index.isValid():
return None

if role == Qt.DisplayRole:
return self._data[index.row()]["name"]

if role == Qt.CheckStateRole:
return Qt.Checked if self._data[index.row()]["checked"] else Qt.Unchecked

def setData(
self, index: QModelIndex, value: typing.Any, role: int = Qt.CheckStateRole
) -> bool:
if role != Qt.CheckStateRole:
return False
if not index.isValid() or index.column() > 0:
return False

# Update the checked state
self._data[index.row()]["checked"] = True if value == Qt.Checked else False
state = "checked" if value == Qt.Checked else "unchecked me"
print(f"Item '{self._data[index.row()]['name']}' is now {state}")

# Notify the view of the change
self.dataChanged.emit(index, index, [Qt.CheckStateRole])
return True

def flags(self, index: QModelIndex) -> Qt.ItemFlags:
if not index.isValid():
return Qt.NoItemFlags
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable

def checked_items(self):
return [it["name"] for it in self._data if it["checked"]]


if __name__ == "__main__":
app = QApplication(sys.argv)

view = QListView()
model = ChoiceModel(
[{"name": "Item 1", "checked": True}, {"name": "Item 2", "checked": False}]
)
view.setModel(model)

view.show()

app.exec()
what is wrong? check box not working , anyone fix this codes for me? checkbox not working

Читать полностью…

C++ & Qt

from PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
import sys
import typing


class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict]) -> None:
super().__init__()
self._data = data

def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
if parent == QModelIndex():
return len(self._data)
return 0

def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> typing.Any:
if not index.isValid():
return None

if role == Qt.DisplayRole:
return self._data[index.row()]["name"]

if role == Qt.CheckStateRole:
return Qt.Checked if self._data[index.row()]["checked"] else Qt.Unchecked

def setData(
self, index: QModelIndex, value: typing.Any, role: int = Qt.CheckStateRole
) -> bool:
if role != Qt.CheckStateRole:
return False
if not index.isValid() or index.column() > 0:
return False

# Update the checked state
self._data[index.row()]["checked"] = True if value == Qt.Checked else False
state = "checked" if value == Qt.Checked else "unchecked me"
print(f"Item '{self._data[index.row()]['name']}' is now {state}")

# Notify the view of the change
self.dataChanged.emit(index, index, [Qt.CheckStateRole])
return True

def flags(self, index: QModelIndex) -> Qt.ItemFlags:
if not index.isValid():
return Qt.NoItemFlags
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable

def checked_items(self):
return [it["name"] for it in self._data if it["checked"]]


if __name__ == "__main__":
app = QApplication(sys.argv)

view = QListView()
model = ChoiceModel(
[{"name": "Item 1", "checked": True}, {"name": "Item 2", "checked": False}]
)
view.setModel(model)

view.show()

app.exec()
what is wrong? check box not working , anyone fix this codes for me? checkbox not working

Читать полностью…

C++ & Qt

from PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
import sys
import typing


class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict]) -> None:
super().__init__()
self._data = data

def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
if parent == QModelIndex():
return len(self._data)
return 0

def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> typing.Any:
if not index.isValid():
return None

if role == Qt.DisplayRole:
return self._data[index.row()]["name"]

if role == Qt.CheckStateRole:
return Qt.Checked if self._data[index.row()]["checked"] else Qt.Unchecked

def setData(
self, index: QModelIndex, value: typing.Any, role: int = Qt.CheckStateRole
) -> bool:
if role != Qt.CheckStateRole:
return False
if not index.isValid() or index.column() > 0:
return False

# Update the checked state
self._data[index.row()]["checked"] = True if value == Qt.Checked else False
state = "checked" if value == Qt.Checked else "unchecked me"
print(f"Item '{self._data[index.row()]['name']}' is now {state}")

# Notify the view of the change
self.dataChanged.emit(index, index, [Qt.CheckStateRole])
return True

def flags(self, index: QModelIndex) -> Qt.ItemFlags:
if not index.isValid():
return Qt.NoItemFlags
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable

def checked_items(self):
return [it["name"] for it in self._data if it["checked"]]


if __name__ == "__main__":
app = QApplication(sys.argv)

view = QListView()
model = ChoiceModel(
[{"name": "Item 1", "checked": True}, {"name": "Item 2", "checked": False}]
)
view.setModel(model)

view.show()

app.exec()
what is wrong? check box not working , anyone fix this codes for me? checkbox not working

Читать полностью…

C++ & Qt

Did you try to add NO_CACHEGEN to the qt6_add_qml_module?

Читать полностью…

C++ & Qt

This is the debugger setting in the run section.
You might also want to check the build section too, to ensure that the debugger is enabled there as well.

Читать полностью…

C++ & Qt

Hi, one fun thing about QML Live preview with QQuickWidget. For some reason Qml live preview handler keep closing QMainWindow. So I added workaround, every time visibilty changes to hidden I call show()

Читать полностью…

C++ & Qt

The Widget and QML are quite different here, and also the forum specifically mentions the QML Debugger.
Since it has a short instruction, I think it’s definitely worth giving it a try!
If it doesn’t work, you might want to try using mingw instead of MSVC and see if that helps.
Good luck :)

Читать полностью…

C++ & Qt

Okay, sorry, I think I misread your first question.
The QMLLS warnings, which I believe should all be gone now, do not have anything to do with the debugger.
However, I think you should check the following links:
https://forum.qt.io/topic/10528/could-not-connect-to-the-in-process-qml-debugger/2
https://doc.qt.io/qtcreator/creator-debugging-qml.html

And since you are using the MSVC++ compiler, you may also want to check your kits and ensure that the MSVC debugger is set up correctly.

Читать полностью…

C++ & Qt

Please. help me use bgl library. boost_1_86_0

Читать полностью…

C++ & Qt

I found that for some reason I didnt need to include it to the .h, but had to include to the .cpp

Читать полностью…

C++ & Qt

It references to the line which is just fine (the code was already written before and I didnt touch it)

Читать полностью…

C++ & Qt

Bunch of errors (unfortunatelly in my native language so I doubt its usefull for u to understand :) )

Читать полностью…

C++ & Qt

It should say exactly what the error is

Читать полностью…

C++ & Qt

Do you mean literally ”include *.h” (which isn’t allowed) or that all h files breaks your code?

Читать полностью…

C++ & Qt

from PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
import sys
import typing


class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict]) -> None:
super().__init__()
self._data = data

def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
if parent == QModelIndex():
return len(self._data)
return 0

def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> typing.Any:
if not index.isValid():
return None

if role == Qt.DisplayRole:
return self._data[index.row()]["name"]

if role == Qt.CheckStateRole:
return Qt.Checked if self._data[index.row()]["checked"] else Qt.Unchecked

def setData(
self, index: QModelIndex, value: typing.Any, role: int = Qt.CheckStateRole
) -> bool:
if role != Qt.CheckStateRole:
return False
if not index.isValid() or index.column() > 0:
return False

# Update the checked state
self._data[index.row()]["checked"] = True if value == Qt.Checked else False
state = "checked" if value == Qt.Checked else "unchecked me"
print(f"Item '{self._data[index.row()]['name']}' is now {state}")

# Notify the view of the change
self.dataChanged.emit(index, index, [Qt.CheckStateRole])
return True

def flags(self, index: QModelIndex) -> Qt.ItemFlags:
if not index.isValid():
return Qt.NoItemFlags
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable

def checked_items(self):
return [it["name"] for it in self._data if it["checked"]]


if __name__ == "__main__":
app = QApplication(sys.argv)

view = QListView()
model = ChoiceModel(
[{"name": "Item 1", "checked": True}, {"name": "Item 2", "checked": False}]
)
view.setModel(model)

view.show()

app.exec()
what is wrong? check box not working , anyone fix this codes for me? checkbox not working

Читать полностью…

C++ & Qt

from PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
import sys
import typing


class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict]) -> None:
super().__init__()
self._data = data

def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
if parent == QModelIndex():
return len(self._data)
return 0

def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> typing.Any:
if not index.isValid():
return None

if role == Qt.DisplayRole:
return self._data[index.row()]["name"]

if role == Qt.CheckStateRole:
return Qt.Checked if self._data[index.row()]["checked"] else Qt.Unchecked

def setData(
self, index: QModelIndex, value: typing.Any, role: int = Qt.CheckStateRole
) -> bool:
if role != Qt.CheckStateRole:
return False
if not index.isValid() or index.column() > 0:
return False

# Update the checked state
self._data[index.row()]["checked"] = True if value == Qt.Checked else False
state = "checked" if value == Qt.Checked else "unchecked me"
print(f"Item '{self._data[index.row()]['name']}' is now {state}")

# Notify the view of the change
self.dataChanged.emit(index, index, [Qt.CheckStateRole])
return True

def flags(self, index: QModelIndex) -> Qt.ItemFlags:
if not index.isValid():
return Qt.NoItemFlags
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable

def checked_items(self):
return [it["name"] for it in self._data if it["checked"]]


if __name__ == "__main__":
app = QApplication(sys.argv)

view = QListView()
model = ChoiceModel(
[{"name": "Item 1", "checked": True}, {"name": "Item 2", "checked": False}]
)
view.setModel(model)

view.show()

app.exec()
what is wrong? check box not working , anyone fix this codes for me? checkbox not working

Читать полностью…

C++ & Qt

from PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
import sys
import typing


class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict]) -> None:
super().__init__()
self._data = data

def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
if parent == QModelIndex():
return len(self._data)
return 0

def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> typing.Any:
if not index.isValid():
return None

if role == Qt.DisplayRole:
return self._data[index.row()]["name"]

if role == Qt.CheckStateRole:
return Qt.Checked if self._data[index.row()]["checked"] else Qt.Unchecked

def setData(
self, index: QModelIndex, value: typing.Any, role: int = Qt.CheckStateRole
) -> bool:
if role != Qt.CheckStateRole:
return False
if not index.isValid() or index.column() > 0:
return False

# Update the checked state
self._data[index.row()]["checked"] = True if value == Qt.Checked else False
state = "checked" if value == Qt.Checked else "unchecked me"
print(f"Item '{self._data[index.row()]['name']}' is now {state}")

# Notify the view of the change
self.dataChanged.emit(index, index, [Qt.CheckStateRole])
return True

def flags(self, index: QModelIndex) -> Qt.ItemFlags:
if not index.isValid():
return Qt.NoItemFlags
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable

def checked_items(self):
return [it["name"] for it in self._data if it["checked"]]


if __name__ == "__main__":
app = QApplication(sys.argv)

view = QListView()
model = ChoiceModel(
[{"name": "Item 1", "checked": True}, {"name": "Item 2", "checked": False}]
)
view.setModel(model)

view.show()

app.exec()
what is wrong? check box not working , anyone fix this codes for me? checkbox not working

Читать полностью…

C++ & Qt

When I turn off the debugger or when I switch it to automatic, the error disappears, but I need a QML debugger 😢
C++ debugger works as expected

Читать полностью…

C++ & Qt

I am not sure I understand what shall I put in qt6_add_qml_module OUTPUT_DIRECTORY

Читать полностью…

C++ & Qt

One more issue is with live reload. I need help. I have qt6_add_qml_module() and live preview works only for changes in the Main.qml file but not the ones which are included. After some debugging I see that QmlEngine loads those files with qrc:/ url, and the IDE or QQmlPreviewFileEngine does not know the mapping between local fs and the qrc so they do not intercept it. Do you also have same issue? Or is it something wrong with my cmake or directory structure?

Читать полностью…

C++ & Qt

The problem is that these instructions include items that are not available in the current version of QtCreator. Before asking the question here, I spent a significant amount of time looking for a solution to the problem myself (I saw these instructions before)
Switching from MSVC to MinGW also doesn't change anything (((

Читать полностью…

C++ & Qt

The forum post is dated 2011, so I think it's slightly out of date :-)
The problem is definitely not in the C++ debugger, because there are no problems with Qt Widgets applications, as with C++ applications in general. Only the connection to the QML debugger is missing for some unknown reason. On my second laptop, on which I haven't installed new programs for a long time, but installed Windows updates, the problems persist. Therefore, the option of occupying the port is excluded as well.
Using different versions of Qt also has no effect.

Читать полностью…

C++ & Qt

Did I do something wrong?

Читать полностью…
Subscribe to a channel