Qt 的一些总结

来源:互联网 发布:优炫软件股份有限公司 编辑:程序博客网 时间:2024/04/29 08:34

1、自己写一个类什么情况下需要继承QObject?

tr函数的翻译功能!!
基本上可以说需要使用Qt的机制的时候:信号槽、事件处理、自动析构、插件机制
2、如何在widget类中设置居中显示
QDesktopWidget* desktop = QApplication::desktop ();
int x = (desktop->width () - this->width ()) / 2;
int y = (desktop->height () - this->height ()) / 2;
this->move (x, y);
3、鼠标移动到控件之上的时候,设置控件为不透明的,而当鼠标移动到其他地方的时候,这个控件透明
MouseArea::onEntered ()当鼠标在这个区域时和退出MouseArea::onExited () 时候设置opacity的值;1为不透明,0为完全透明
4、怎么改变链接中字体百度的颜色
QLabel *label = new QLabel("<a href = http://wwww.baidu.com><font color = 'red'>百度</font></a>");
5、让当前程序重启:
   QProcess::startDetached(QApplication::applicationFilePath());
   close();

//以后会陆续添加
0 0