Skip to content

Commit 95422ea

Browse files
authored
Use QString. (#71)
1 parent 898a410 commit 95422ea

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

examples/groups/mainwindow_funcs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ MainWindow::MainWindow() : QMainWindow()
3939
[a, b, c](const auto x) { return 5.0 + a * sin(x) + b * sin(2.0 * x) - c * sin(3.0 * x); });
4040

4141
// Create a renderable and add it to the group
42-
auto *renderable = ui_.TestingWidget->addData1D(std::string("Sines") + std::to_string(n));
42+
auto *renderable = ui_.TestingWidget->addData1D(QString("Sines%1").arg(n));
4343
renderable->setData(xValues, y);
4444

4545
renderable->colour().set({int(255 * dist(gen)), int(255 * dist(gen)), int(255 * dist(gen)), 255});

src/entities/data.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DataEntity : public Qt3DCore::QEntity
3131
*/
3232
protected:
3333
// Display name for entity
34-
std::string displayName_;
34+
QString displayName_;
3535
// Extrema of data points in three-dimensional space
3636
Cuboid extrema_;
3737
// Extrema of data points in three-dimensional logarithmic space
@@ -112,4 +112,4 @@ class DataEntity : public Qt3DCore::QEntity
112112
// Recreate renderables following metric / axis change
113113
void updateRenderables();
114114
};
115-
} // namespace Mildred
115+
} // namespace Mildred

src/version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace Mildred
1111
namespace Version
1212
{
1313
// Return version
14-
std::string_view version() { return MILDREDVERSION; }
14+
QString version() { return MILDREDVERSION; }
1515
// Return short hash
16-
std::string_view shortHash() { return MILDREDSHORTHASH; }
16+
QString shortHash() { return MILDREDSHORTHASH; }
1717
// Return repo url
18-
std::string_view repoUrl() { return MILDREDREPO; }
18+
QString repoUrl() { return MILDREDREPO; }
1919
}; // namespace Version
2020
}; // namespace Mildred

src/widget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ RenderableMaterial *MildredWidget::createMaterial(Qt3DCore::QEntity *parent, Ren
178178
}
179179

180180
// Add new 1-dimensional data entity for supplied data
181-
Data1DEntity *MildredWidget::addData1D(std::string_view tag)
181+
Data1DEntity *MildredWidget::addData1D(const QString &tag)
182182
{
183183
// Check for existing tag
184184
auto it = std::find_if(dataEntities_.begin(), dataEntities_.end(), [tag](const auto &d) { return tag == d.first; });
185185
if (it != dataEntities_.end())
186186
{
187-
printf("Data with tag '%s' already exists, so can't add it again.\n", it->first.c_str());
187+
qDebug() << QString("Data with tag '%1' already exists, so can't add it again.\n").arg(it->first);
188188
throw(std::runtime_error("Duplicate DataEntity tag created.\n"));
189189
}
190190

@@ -214,4 +214,4 @@ DisplayGroup *MildredWidget::addDisplayGroup()
214214
auto newGroup = displayGroups_.emplace_back(std::make_shared<DisplayGroup>());
215215

216216
return newGroup.get();
217-
}
217+
}

src/widget.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class MildredWidget : public QWidget
193193
*/
194194
private:
195195
// Associated data entities (with identifying tag)
196-
std::vector<std::pair<std::string, DataEntity *>> dataEntities_;
196+
std::vector<std::pair<QString, DataEntity *>> dataEntities_;
197197

198198
private:
199199
// Create material for specified entity
@@ -205,7 +205,7 @@ class MildredWidget : public QWidget
205205

206206
public:
207207
// Add new data entity for supplied data
208-
Data1DEntity *addData1D(std::string_view tag);
208+
Data1DEntity *addData1D(const QString &tag);
209209

210210
/*
211211
* Grouping
@@ -218,4 +218,4 @@ class MildredWidget : public QWidget
218218
// Create new display group
219219
DisplayGroup *addDisplayGroup();
220220
};
221-
} // namespace Mildred
221+
} // namespace Mildred

0 commit comments

Comments
 (0)