从在QT4中找不到QT3中的类 QT4与QT3的兼容

news/2024/5/18 23:54:22 标签: qt, signal

最近在研究QT,

但是教程是 QT3版本的..

而自己现在的QT是QT4版本了。后多原来qt3的类都不在了。但是想想又有点不对劲啊,哪有新版本全部否定老版本的啊,这不是砸自己的脚吗?后来又查了下,才发现qt4还是支持qt3的。QT4中提供了大量新控件,也保持了旧的控件,并命名为Qt3XXX,并且全都放到“/qt/include/Qt3Support”这个文件夹下面去了,哪些没有被修改的控件则继续放在原来的文件夹下面。在上一篇博文中我们介绍了在建项目的时候要“select required modules”,我们如果要使用qt3中的文件,我们就要在“Qt3Support modules”前面打钩,将这个选中就可以了。

下面是qt3与qt4的举例

qt3下面的源程序是:

#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qvbox.h>
int main( int argc, char **argv )
{
    QApplication a( argc, argv );
    QVBox box;
    box.resize( 200, 120 );
    QPushButton quit( "Quit", &box );
    quit.setFont( QFont( "Times", 18, QFont::Bold ) );
    QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) );
    a.setMainWidget( &box );
    box.show();
    return a.exec();
}
qt4中修改为:

#include <qapplication.h>

qt-block-indent: 0; qt-user-state: 0;">#include <qpushbutton.h>

qt-block-indent: 0; qt-user-state: 0;">#include <qfont.h>

qt-block-indent: 0; qt-user-state: 0;">#include <q3vbox.h>

qt-block-indent: 0; qt-paragraph-type: empty;"> 

qt-block-indent: 0; qt-user-state: 0;">int main( int argc, char **argv )

qt-block-indent: 0; qt-user-state: 256;">{

qt-block-indent: 0; qt-user-state: 256;">QApplication a( argc, argv );

qt-block-indent: 0; qt-user-state: 256;">Q3VBox box;

qt-block-indent: 0; qt-user-state: 256;">box.resize( 200, 120 );

qt-block-indent: 0; qt-user-state: 256;">QPushButton quit( "Quit", &box );

qt-block-indent: 0; qt-user-state: 256;">quit.setFont( QFont( "Times", 18, QFont::Bold ) );

qt-block-indent: 0; qt-user-state: 256;">QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) );

qt-block-indent: 0; qt-user-state: 256;">a.setMainWidget( &box );

qt-block-indent: 0; qt-user-state: 256;">box.show();

qt-block-indent: 0; qt-user-state: 256;">return a.exec();

qt-block-indent: 0; qt-user-state: 0;">}

qt-block-indent: 0; qt-paragraph-type: empty;"> 


http://www.niftyadmin.cn/n/1790820.html

相关文章

Windows下ElasticSearch及相关插件的安装

&#xff08;1&#xff09;在官网下载ElasticSearch压缩包。这里我下载的是elasticsearch-1.7.1&#xff08;下载地址&#xff1a;https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.1.zip&#xff09;。&#xff08;2&#xff09;选择电脑上的某个位…

QT4 自定义槽和信号

QT4 自定义槽和信号本文所示代码在windows xp MingW3.4.2 eclipse3.4CDT5.0版本中调试通过QT系统为我们提供功能非常全面信号处理机制&#xff0c;它的内制信号和槽已经非常全面&#xff0c;因此大多数情况下&#xff0c;我们不需要自己设计信号和槽&#xff0c;但是有些时候&…

数字图像处理 冈萨雷斯 中文第三版 习题

x/0.3a/0.014.推出x21.43a a的值是锥状体的大小。将中央凹看成方形的计算方法&#xff0c;337000开根号581&#xff0c;即在1.5mm1.5mm的区域上&#xff0c;锥状体分布约等于581581&#xff0c;每个锥状体的大小&#xff08;假设锥状体和锥状体之间的间隔是一样大&#xff09;a…

ES6相关特性(解构赋值)

解构赋值&#xff1a;本质上是一种匹配模式&#xff0c;等号两边的模式相同&#xff0c;则左边的变量可以被赋予对应的值。 注意&#xff1a;null & undefined 不能解构赋值&#xff01;&#xff01;&#xff01; 数组的解构赋值&#xff1a; let [a,[[b],c]][1,[[2],3]]; …

Qt经典出错信息之undefined reference to `vtable for classname

这个出错信息太常见了&#xff0c;用过Qt两个月以上的朋友基本上都能自己解决了&#xff0c;因为太经典了&#xff0c;可以给新手参考。 出错信息一般类似:undefined reference to vtable for classname MyWidget在执行make命令后出现。 出错原因是在定义类的时候为了能使用s…

POJ-3159-Candies-(差分约束,Dijkstra)

链接&#xff1a;https://vjudge.net/problem/POJ-3159 题意&#xff1a; N个小孩&#xff0c;M个约束 以A&#xff0c;B&#xff0c;C给出。即小孩B的糖果不能比A多C以上。 思路&#xff1a; 差分约束&#xff1a; 若有 A-B < V1,B-C < V2,即A-C < V1V2。 用最短路求…

Windows环境下利用Qt连接MYSQL数据库

在Windows下面利用QT开发数据库应用&#xff0c;如MYSQL&#xff0c;首先&#xff0c;我们必须利用源码编译MYSQL驱动库&#xff1b; 1&#xff09;安装qt-sdk-win-opensource-2010.02.1.exe 此时&#xff0c;QT安装了QT Creator&#xff0c;假定目录为&#xff1a; E:/Qt/2…

session删除

<?phpsession_start();//删除session$_SESSIONarray();//删除客户端cookie中存储的sessionID值if(isset($_COOKIE[session_name()])){setcookie(session_name(),,0,/);}session_destroy(); ?> 转载于:https://www.cnblogs.com/hometown/p/6944796.html