错误:'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. mysql中索引利用情况(explain用法)

    使用explain查看,如下 1.首先创建表test,语句如下 create table test(a int,b varchar(10),c varchar(10)); 2.在表中的a,b都创建索引 ...

  2. 推荐给开发者的11个PHP框架(转)

    PHP框架对于Web开发者来说是非常有用的工具,它可以帮助使用者更快.更容易的完成项目.根据调查,PHP仍是Web开发中最受欢迎和最实用的平台之一.当谈及Web开发时,很多人依然会选择使用PHP框架, ...

  3. vue-cli Uncaught SyntaxError: Use of const in strict mode解决办法

    vue-cli初始化项目,开发环境运行项目使用了webpack-dev-server,而最新版本webpack-dev-server@2.9.1运行项目时,并不能成功的把es6语法转化为es5,所以在 ...

  4. Rem实现移动端适配

    移动端适配 web页面跑在手机端(h5页面) 跨平台 基于webview() 基于webkit 常见适配方法 pc端采用display:inline-block,让div盒子横着排 移动web:采用定 ...

  5. Linux中pid_t类型为int类型

    1. 查看man手册,找到pid_t,可以通过getpid函数来看 2. 打开sys/types.h 3. 打开bits/types.h 4. 打开bits/typesizes.h 找不到相关的头文件 ...

  6. nyi63——树

    #include<bits/stdc++.h> using namespace std; int cnt; struct node { int data; int flag; node * ...

  7. 【Python】日期模块总结

    Time Tuple: 索引 字段 值 0 年(四位数字) 2015 1 月份 1 - 12 2 日期 1 - 31 3 小时 0 - 23 4 分钟 0 - 59 5 秒 0 - 61 (60 或 ...

  8. 十五、dbms_space(分析段增长和空间的需求)

    1.概述 作用:用于分析段增长和空间的需求. 2.包的组成 1).unused_space作用:用于返回对象(表.索引.簇)的未用空间语法:dbms_space.unused_space(segmen ...

  9. django-pymysql-封装的sql使用

    封装的sql import pymysql def get_list(sql,args): conn = pymysql.connect(host=, user='root', passwd='', ...

  10. LeetCode OJ:Implement Stack using Queues(队列实现栈)

    Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. po ...