我正在尝试将MarbleWidget集成到QT项目中。如果我只想显示这样的小部件:
Marble::MarbleWidget *mapWidget = new Marble::MarbleWidget();
mapWidget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
mapWidget->show()
一切都很好。但我想要做的是将小部件集成到现有窗口中。我做的是我使用QtDesigner添加了一个小部件,将小部件提升为Marble :: MarbleWidget,然后使用以下代码:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->widget = new Marble::MarbleWidget();
ui->widget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
ui->setupUi(this);
}
我可以看到小部件,但没有地图:
我在控制台上看到以下错误:
QObject::connect: No such signal MarbleWebView::titleChanged(QString) in ~/marble/sources/src/lib/marble/PopupItem.cpp:71
QObject::connect: (sender name: 'webView')
QObject::connect: (receiver name: 'titleText')
QObject::connect: No such signal MarbleWebView::urlChanged(QUrl) in ~/marble/sources/src/lib/marble/PopupItem.cpp:72
QObject::connect: (sender name: 'webView')
QObject::connect: No such signal MarbleWebView::titleChanged(QString) in ~/marble/sources/src/lib/marble/PopupItem.cpp:71
QObject::connect: (sender name: 'webView')
QObject::connect: (receiver name: 'titleText')
QObject::connect: No such signal MarbleWebView::urlChanged(QUrl) in ~/marble/sources/src/lib/marble/PopupItem.cpp:72
QObject::connect: (sender name: 'webView')
我做错了什么?
答案 0 :(得分:1)
当您在设计器中提升窗口小部件时,该窗口小部件将是您升级到的类的实例。
你在这里做的是创建另一个Marble :: Widget并告诉第二个大理石小部件加载数据。
您提升的是# recreate your data
df <- data.frame(rbind(c(1:3, "aa"), c(2:4, "bb"), c(3:5, "aa"), c(4,1,6, "bb"), c(2:4, "aa"), c(3:5, "bb")))
df[,1:3] <- apply(df[,1:3], 2, as.integer)
# split it
blank1 <- df[5,]
blank2 <- df[6,]
df <- df[1:4,]
for (i in 1:nrow(df)) {
if (df[i,4] == "aa") {df[i,1:3] <- df[i,1:3] - blank1[1:3]}
else {df[i,1:3] <- df[i,1:3] - blank2[1:3]}
}
指针的某个成员,您需要在该对象上调用ui
。
答案 1 :(得分:1)
凯文说。代码方面将是
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->widget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
}