我已经创建了一个 Qt GUI 应用程序,但我没有触及任何关于 GUI 的内容。我已经修改了 mainwindow.cpp 和项目文件。
主窗口.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QWebPage>
#include <QWebFrame>
QWebPage page;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(page.mainFrame(), SIGNAL(loadFinished(bool)), this, SLOT(pageLoaded1(bool)));
QUrl router("http://192.168.1.1");
page.mainFrame()->load(router);
}
MainWindow::~MainWindow()
{
delete ui;
}
无标题.pro:
#-------------------------------------------------
#
# Project created by QtCreator 2013-05-01T23:48:00
#
#-------------------------------------------------
QT += core gui webkit webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
主.cpp:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
错误:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Error!
Program: ...tled-Desktop_Qt_5_0_2_MSVC2010_32bit-Debug\debug\untitled.exe
Module: 5.0.2
File: global\qglobal.cpp
Line: 1977
ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 962
(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
此处插入额外字符以绕过字符要求。