【发布时间】:2015-01-05 11:05:29
【问题描述】:
我在使用课程时确实遇到了问题。
我确实有一个主文件定义如下:
int main(int argc, char *argv[])
{
uint32_t error;
QApplication app(argc, argv);
QPalette pal = app.palette();
pal.setColor(QPalette::Window, Qt::white);
app.setPalette(pal);
// Detecting puls device
mtp_wrapper *MyDevice = new mtp_wrapper;
error = MyDevice->ConnectDevice();
if(error != ERROR_NONE) {
app.quit();
}
else {
MyDevice->Properties();
MyDevice->DeviceScan();
app.setOrganizationName("i.am+");
app.setApplicationName("PULS");
MainWindow MyMainWindow(MyDevice);
MyMainWindow->show();
return app.exec();
}
}
我的问题是 MainWindow MyMainWindow(MyDevice);似乎没有正确初始化。
mtp_wrapper 类定义如下:
mtp_wrapper::mtp_wrapper() : DeviceMngr(NULL)
{
LIBMTP_Init();
DeviceMngr = new Device_struct;
DeviceMngr->deviceConnected = false;
}
Device_struct 是一个结构,其中包含定义设备的变量列表。
为了在 mainWindow 程序(这是我的用户界面部分)中使用此信息,我将 MainWindow 定义如下:
主窗口.h
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(mtp_wrapper& device);
private:
/* Mtp device access */
mtp_wrapper& m_device;
...
}
MainWindow.cpp
MainWindow::MainWindow(mtp_wrapper& device) :
m_device(device)
{
resize(800,600);
setUnifiedTitleAndToolBarOnMac(true);
/* Creation of the Top bar section */
...
}
我遇到的错误是初始化主窗口没有匹配的构造函数。
感谢您的帮助
【问题讨论】: