错误:'class QApplication' has no member named 'setMainwidget'

转自:http://blog.csdn.net/chenqiai0/article/details/8648246

在学习 QT的过程中 遇到了一个问题

错误如下:
'class QApplication' has no member named 'setMainWidget'

在 类QApplication里面 没有找到 setMainWidget 成员...

原因是:
Qt 3.x支持setMainWidget,但是Qt4已经取消了对setMainWidget的支持。

以下是一个QT3程序

#include<qapplication.h>

#include<qpushbutton.h>

int main( int argc, char*argv[])

{

QApplicationa( argc, argv );

QPushButtonhello( "Hello world!", 0 );

hello.resize( 100, 30 );

a.setMainWidget( &hello );

hello.show();

returna.exec();

}

*********************************

a.setMainWidget(&hello );

这个按钮被选为这个应用程序的主窗口部件。如果用户关闭了主窗口部件,应用程序就退出了。你不用必须设置一个主窗口部件,但绝大多数程序都有一个。

修改之后的QT4程序

#include<QApplication>

#include<QPushButton>

int main( int argc, char* argv[])

{

QApplication app(argc, argv );

QPushButton*hello = new QPushButton( "Hello world!", 0 );

hello-> resize( 100, 30 );

hello-> show();

return app.exec();

}

 

错误:'class QApplication' has no member named 'setMainwidget'的更多相关文章

  1. 安装Stomp扩展时错误提示error: 'zend_class_entry' has no member named 'default_properties'

    在安装stomp扩展时, 有这样的提示 error: 'zend_class_entry' has no member named 'default_properties' 交待下安装上下文, sto ...

  2. 【Linux】解决"no member named 'max_align_t'

    编译遇到错误: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.1/../../../../include/c++/5.4.1/cstddef:51:11: erro ...

  3. ushare编译之 ‘struct sockaddr_storage’ has no member named ‘s_addr’

    编译ushare的时候出现'struct sockaddr_storage' has no member named 's_addr' 这是使用libupnp1.6.19出现版本号不兼容的错误. 解决 ...

  4. CAFFE(FAQ.2):Ubuntu 配置caffe 框架之数据库读取,错误解决:ImportError: No module named leveldb解决办法

    Z: 在安装了caffe框架后需要读取大量的数据进行学习训练.比如在MNIST识别训练中,一般直接读图片会比较耗时,我们一般将图片转存为数据库中.目前主流的数据库有以下两种选择: LevelDB Lm ...

  5. 利用virtualenvwrapper创建虚拟环境出现错误“/usr/bin/python: No module named virtualenvwrapper”

    Linux:CentOS7 python: 系统默认python版本2.7,利用python启动 自己安装python版本3.8,利用python3启动 问题描述: 在上述环境中利用virtualen ...

  6. django之异常错误2(Error was: No module named sqlite3.base)

    具体错误代码为: C:\djangoweb\helloworld>manage.py syncdbTraceback (most recent call last):  File "C ...

  7. ubuntu16安装pylearn2 出现错误提示importerror:no module named six.moves

    由于市面上的一些教程时间比较早,入门学习时跟随教程安装容易出现各种错误,这些错误基本都是版本不同导致的 所以,我们安装过程中一定要指出包的版本,如果你已经遇到no module named six.m ...

  8. Spark wordcount 编译错误 -- reduceByKey is not a member of RDD

    Attempting to run http://spark.apache.org/docs/latest/quick-start.html#a-standalone-app-in-scala fro ...

  9. laravel和lumen数据库链接错误_FatalErrorException Call to a member function connection

    FatalErrorException in Model.php line 3339: Call to a member function connection() on null 挺简单的一个lum ...

随机推荐

  1. Enter键禁止表单提交

    Enter键禁止表单提交js代码: //禁用Enter键表单自动提交 document.onkeydown = function (event) { var target, code, tag; if ...

  2. .Net Core 二级域名绑定到指定的控制器

    在说二级域名绑定之前,先说一下.net core中的区域,关于区域这一块儿在很久之前的博客中,已经提过,详见<03-dotnet core创建区域[Areas]及后台搭建>,在这篇博客中, ...

  3. Mysql5.7基于日志主从复制

    主从同步概念 主从同步是异步复制 Mysql两种复制类型: 基于二进制日志 使用GTID完成基于事务的复制 基于日志三种方式: Mysql5.7需要注意的问题: 老版本方法创建mysql用户 #mys ...

  4. zoj4028 LIS,差分约束

    题意:给你以i为结尾的最长上升子序列的值,和每个值的区间范围求可行的a[i] 题解:差分约束,首先满足l[i]<=a[i]<=r[i],可以建一个虚拟节点n+1,那么有a[n+1]-a[i ...

  5. rabbitmq&&erlang 安装

    # yum install epel-release CentOS and Red Hat Enterprise Linux 6.x wget https://dl.fedoraproject.org ...

  6. FortiDDoS是使用历史流量基线进行检测的

    Understanding FortiDDoS Detection ModeIn Detection Mode, FortiDDoS logs events and builds traffic st ...

  7. BZOJ2259 [Oibh]新型计算机

    话说hzwer你在坑爹?... 我按照你的建图交了上去,发现WA. 开始检查= =...过了好久,突然觉得画风不对...hzwer您建图错了啊!!! 后来看了看zky的终于知道了怎么回事>_&l ...

  8. laravel中的validate验证的使用案例:

    第一个是设置,第二个是直接调用.

  9. 部署C# ReportViewer遇到的坑

    前些天临时给客户做个工具,统计具体时间点各种车型数据的数量及比重,为了显示方便就用C#来做,因为它有现成的reportviwer控件提供了显示,打印,导出功能.原本我以为这个控件是.netframew ...

  10. HtmlHelper.Raw,<%%>,<%:%>,<%=%>的区别及使用

    Mvc中<%%>,<%:%>,<%=%>的区别及使用 1.<%%> <%%>之间可以执行服务端代码,如<% foreach (Data ...