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
I guess you need to call setRowCount (and setColumnCount) in the model constructor. If this is not helping, give a more precise description of what is not working.
Читать полностью…I need functionality of
nx.algorithms.has_path(g, node_addr1, node_addr2)Читать полностью…
I need functionality of
nx.algorithms.has_path(g, node_addr1, node_addr2)Читать полностью…
I need functionality of
nx.algorithms.has_path(g, node_addr1, node_addr2)Читать полностью…
Another question what is the minimal condition for covariance? isnt it enough that class B inherits class A?
Читать полностью…Perhaps you have to add some include directories? Perhaps the header file you included tries to include other files?
Читать полностью…A good strategy is to focus on the first error. Solving that often makes the rest go away too.
Читать полностью…Last few hours when I was getting error it was 100% clear what happened, now its just a pile of a mess
Читать полностью…I meant a single .h file that I include into another .h causes the build error
Читать полностью…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?
Читать полностью…from PySide6.QtWidgets import QApplication, QListViewwhat is wrong? check box not working , anyone fix this codes for me? checkbox not working Читать полностью…
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()
from PySide6.QtWidgets import QApplication, QListViewwhat is wrong? check box not working , anyone fix this codes for me? checkbox not working Читать полностью…
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()
from PySide6.QtWidgets import QApplication, QListViewwhat is wrong? check box not working , anyone fix this codes for me? checkbox not working Читать полностью…
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()
Did you try to add NO_CACHEGEN
to the qt6_add_qml_module
?
import sys
import typing
from PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict], parent=None) -> None:
super().__init__(parent=parent)
self._data = data
def rowCount(self, parent = QModelIndex) -> int:
return len(self._data)
def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> typing.Any:
ret = None
if not self._data:
ret = None
if not index.isValid():
ret = None
if role == Qt.ItemDataRole.DisplayRole:
ret = self._data[index.row()]["name"]
if role == Qt.ItemDataRole.CheckStateRole:
ret = Qt.CheckState.Checked if self._data[index.row()]["checked"] else Qt.CheckState.Unchecked
return ret
def setData(self, index: QModelIndex, value: typing.Any, role = Qt.ItemDataRole.CheckStateRole) -> bool:
if not index.isValid():
return False
if role == Qt.ItemDataRole.CheckStateRole:
self._data[index.row()]["checked"] = False if value == 0 else True
self.dataChanged.emit(index, index, [Qt.ItemDataRole.CheckStateRole])
return True
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
if not index.isValid():
return Qt.ItemFlag.NoItemFlags
return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsUserCheckable
if __name__ == "__main__":
app = QApplication(sys.argv)
view = QListView()
view.setWindowTitle('Choice Model List View')
model = ChoiceModel([{"name": "Item 1", "checked": True}, {"name": "Item 2", "checked": False}])
view.setModel(model)
view.setMinimumSize(400, 600)
view.show()
sys.exit(app.exec())
x: int == y: int.
what I've tried so far. get shortest path as array
struct VertexBB {Читать полностью…
uint64_t id;
std::vector<Instr_with_content> instrs;
};
struct Edge {
uint64_t from_id;
uint64_t to_id;
};
//using BGraph = boost::directed_graph<VertexBB, Edge>;
using BGraph = boost::adjacency_list<
boost::vecS,
boost::vecS,
boost::directedS,
VertexBB,
Edge>;
typedef boost::graph_traits<BGraph>::vertex_descriptor VertexDesc;
typedef boost::graph_traits<BGraph>::edge_descriptor EdgeDesc;
std::vector<VertexDesc> getPath(
const BGraph& graph,
const std::vector<VertexDesc>& pMap,
const VertexDesc source,
const VertexDesc destination
) {
std::vector<VertexDesc> path;
//VertexDesc current = destination;
//while (current != source)
//{
// path.push_back(current);
// current = pMap[current];
//}
//path.push_back(source);
//return path;
VertexDesc current = destination;
do {
auto const pred = pMap.at(current);
std::cout << "extract path: " << std::hex << graph[current].id << " <- "
<< std::hex << graph[pred].id << "\n";
if (current == pred)
break;
current = pred;
path.push_back(current);
} while (current != source);
std::reverse(path.begin(), path.end());
return path;
}
std::vector<VertexDesc> djikstra(
const BGraph& graph,
const VertexDesc source,
const VertexDesc destination
) {
const int numVertices = boost::num_vertices(graph);
std::vector<int> distances(numVertices);
std::vector<VertexDesc> pMap(numVertices);
auto distanceMap =
boost::predecessor_map(
boost::make_iterator_property_map(
pMap.begin(),
boost::get(boost::vertex_index, graph)))
.distance_map(
boost::make_iterator_property_map(
distances.begin(),
boost::get(boost::vertex_index, graph)))
.weight_map(boost::make_constant_property<EdgeDesc>(1.0));
boost::dijkstra_shortest_paths(graph, source, distanceMap);
return getPath(graph, pMap, source, destination);
}
.....
calling
std::vector<VertexDesc> path = djikstra(BGWTA.graph, vd_node, vd_node1);
path.size is ALWAYS 0
what I've tried so far. get shortest path as array
struct VertexBB {Читать полностью…
uint64_t id;
std::vector<Instr_with_content> instrs;
};
struct Edge {
uint64_t from_id;
uint64_t to_id;
};
//using BGraph = boost::directed_graph<VertexBB, Edge>;
using BGraph = boost::adjacency_list<
boost::vecS,
boost::vecS,
boost::directedS,
VertexBB,
Edge>;
typedef boost::graph_traits<BGraph>::vertex_descriptor VertexDesc;
typedef boost::graph_traits<BGraph>::edge_descriptor EdgeDesc;
std::vector<VertexDesc> getPath(
const BGraph& graph,
const std::vector<VertexDesc>& pMap,
const VertexDesc source,
const VertexDesc destination
) {
std::vector<VertexDesc> path;
//VertexDesc current = destination;
//while (current != source)
//{
// path.push_back(current);
// current = pMap[current];
//}
//path.push_back(source);
//return path;
VertexDesc current = destination;
do {
auto const pred = pMap.at(current);
std::cout << "extract path: " << std::hex << graph[current].id << " <- "
<< std::hex << graph[pred].id << "\n";
if (current == pred)
break;
current = pred;
path.push_back(current);
} while (current != source);
std::reverse(path.begin(), path.end());
return path;
}
std::vector<VertexDesc> djikstra(
const BGraph& graph,
const VertexDesc source,
const VertexDesc destination
) {
const int numVertices = boost::num_vertices(graph);
std::vector<int> distances(numVertices);
std::vector<VertexDesc> pMap(numVertices);
auto distanceMap =
boost::predecessor_map(
boost::make_iterator_property_map(
pMap.begin(),
boost::get(boost::vertex_index, graph)))
.distance_map(
boost::make_iterator_property_map(
distances.begin(),
boost::get(boost::vertex_index, graph)))
.weight_map(boost::make_constant_property<EdgeDesc>(1.0));
boost::dijkstra_shortest_paths(graph, source, distanceMap);
return getPath(graph, pMap, source, destination);
}
.....
calling
std::vector<VertexDesc> path = djikstra(BGWTA.graph, vd_node, vd_node1);
path.size is ALWAYS 0
what I've tried so far. get shortest path as array
struct VertexBB {Читать полностью…
uint64_t id;
std::vector<Instr_with_content> instrs;
};
struct Edge {
uint64_t from_id;
uint64_t to_id;
};
//using BGraph = boost::directed_graph<VertexBB, Edge>;
using BGraph = boost::adjacency_list<
boost::vecS,
boost::vecS,
boost::directedS,
VertexBB,
Edge>;
typedef boost::graph_traits<BGraph>::vertex_descriptor VertexDesc;
typedef boost::graph_traits<BGraph>::edge_descriptor EdgeDesc;
std::vector<VertexDesc> getPath(
const BGraph& graph,
const std::vector<VertexDesc>& pMap,
const VertexDesc source,
const VertexDesc destination
) {
std::vector<VertexDesc> path;
//VertexDesc current = destination;
//while (current != source)
//{
// path.push_back(current);
// current = pMap[current];
//}
//path.push_back(source);
//return path;
VertexDesc current = destination;
do {
auto const pred = pMap.at(current);
std::cout << "extract path: " << std::hex << graph[current].id << " <- "
<< std::hex << graph[pred].id << "\n";
if (current == pred)
break;
current = pred;
path.push_back(current);
} while (current != source);
std::reverse(path.begin(), path.end());
return path;
}
std::vector<VertexDesc> djikstra(
const BGraph& graph,
const VertexDesc source,
const VertexDesc destination
) {
const int numVertices = boost::num_vertices(graph);
std::vector<int> distances(numVertices);
std::vector<VertexDesc> pMap(numVertices);
auto distanceMap =
boost::predecessor_map(
boost::make_iterator_property_map(
pMap.begin(),
boost::get(boost::vertex_index, graph)))
.distance_map(
boost::make_iterator_property_map(
distances.begin(),
boost::get(boost::vertex_index, graph)))
.weight_map(boost::make_constant_property<EdgeDesc>(1.0));
boost::dijkstra_shortest_paths(graph, source, distanceMap);
return getPath(graph, pMap, source, destination);
}
.....
calling
std::vector<VertexDesc> path = djikstra(BGWTA.graph, vd_node, vd_node1);
path.size is ALWAYS 0
I found that for some reason I didnt need to include it to the .h, but had to include to the .cpp
Читать полностью…It references to the line which is just fine (the code was already written before and I didnt touch it)
Читать полностью…Bunch of errors (unfortunatelly in my native language so I doubt its usefull for u to understand :) )
Читать полностью…Do you mean literally ”include *.h” (which isn’t allowed) or that all h files breaks your code?
Читать полностью…from PySide6.QtWidgets import QApplication, QListViewwhat is wrong? check box not working , anyone fix this codes for me? checkbox not working Читать полностью…
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()
from PySide6.QtWidgets import QApplication, QListViewwhat is wrong? check box not working , anyone fix this codes for me? checkbox not working Читать полностью…
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()
from PySide6.QtWidgets import QApplication, QListViewwhat is wrong? check box not working , anyone fix this codes for me? checkbox not working Читать полностью…
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()
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
I am not sure I understand what shall I put in qt6_add_qml_module OUTPUT_DIRECTORY
Читать полностью…