cplusplusqt | Unsorted

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

1220

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

Use Qt IDE for C++ .

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

C++ & Qt

Can anyone here point me to the implementation of ArcItem (qml mcus) in github repo...

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

C++ & Qt

Then you'll need to do some reverse engineering, and the data will depend on how it was compiled. I do not think you will ever be able to recover the Python version at all

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

C++ & Qt

How was it compiled? I think it will be hard to recover the actual source code, but you may be able to get something.

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

C++ & Qt

Welcome to the group, -! :-)

Wanna share your story of how you started with Qt, QML or C++? Maybe some nice feature that made you stick with it.
Rules are set on the description of the group. :)

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

C++ & Qt

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())


The value received from the setData function value argument is an int data type while Qt.CheckState Enum is a Literal, to implement a toggle logic you will have to make comparison with integer values
 x: int == y: int
.
You will see that the value arg from setData() -> [Unchecked == 2, Checked == 0]

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

C++ & Qt

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

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

C++ & Qt

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

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

C++ & Qt

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

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

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

How to download turbo c++

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

C++ & Qt

Hi
I have been a qml / c++ dev for past 1.5 yrs..and here to make connections and interact/ brainstorm ideas

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

C++ & Qt

I learned through a program that it was written in Python and compiled with C++.

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

C++ & Qt

Hello, is it possible to access the source code of an exe file written in Python and compiled with C++?

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

C++ & Qt

someone fixed for me, thanks bro

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

C++ & Qt

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.

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

C++ & Qt

I need functionality of

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

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

C++ & Qt

I need functionality of

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

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

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?

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