博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Qt interview questions
阅读量:5420 次
发布时间:2019-06-15

本文共 4485 字,大约阅读时间需要 14 分钟。

1. Describe Signals & Slots.

A: Signals ans Slots are used for communication between objects. It shall replace generally way of callbacks to avoid the flaws from callbacks.

    Any class deprived from QObject can have its own signals and slots.

  

2. How Signals & Slots work? What is MetaObject system?
3. Object and signals & slots.
4. QObject related. What class do i need to inherit if i want to have signals & slots?OR Why is QObject a special class?
5. What is O_OBJECT macro? Do you know what it expands into?
6. What are slots?
7. Can i call a slot normally?

A: yes, of course. You can define slot as normal member functions.  You can use identifier public, proteced and private to set the scope of each slots functions.

8. Can slots be virtual?

A: yes, it can be defined as virtual and can be inherited by child class.

     It even can be pure virual like:

classBaseConfigurationPage:publicQWidget{
// Some constructor and other methods, irrelevant here. public slots:       virtualvoid loadSettings()=0;    virtual void saveSettings()=0; }; classGeneralConfigurationPage:publicBaseConfigurationPage{
// Some constructor and other methods, irrelevant here. //public slots: do not need this here any more   void loadSettings();   void saveSettings(); };

      Just like regular c++ pure virtual methods. The code generated by MOC does call the pure virtual slots, but that's ok since the base class can't be instantiated anyway...

      Again, just like regular c++ pure virtual methods, the class cannot be instantiated until the methods are given an implementation.

      One thing: in the subclass, you actuallly don't need to mark the overriden methods as slots. One, they're already implemented as slots in the base class. Two, you're just creating more work for the MOC and compiler since you're adding a (tiny) bit more code. Trivial, but whatever.

 

9. Can i call a Signal normally?

A: no, you can not. only can be emit. (?)

10. Give the syntax/prototype of connect().

A: connect (obj1, SIGNAL(sigFunc(arg...)), obj2, SLOT(slotFunc(arg...)));

11. Can i connect two signals? how?

A: Yes. things work like pass this events from one object to another object.

    --- connect (obj1, SIGNAL(sigFun()), obj2, SIGNAL(sigOtherFunc()));

12. What is the order of calling of slots connected to the same signal?

A: If it is in single process(thread) mode, it shall be called in sequence of the definition of connect.

    Ifi it is in Multiple threads mode, need to check

13. What are the container classes you have used in Qt?

A: QVector, QMap, QList, Q

14. What is the difference between QList, QLinkedList, QVector etc.

15. What is implicit sharing? How Qt uses it.

16. Question: What is the difference between close() and hide() in Qt?

Answer:
1) A close event is sent before the widget closes and can be ignored, in this case the Window won't close. A hide event is sent when the widget has been hidden.
2) close() deletes the closed widget if the WDestructiveClose flag has been set during construction of the widget. If that flag has not been set you have to delete the widget yourself. When you delete the form the widgets on the form will be deleted as well.
Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().

(1) Why Qt does not use templates for signals/slot implementation?

(2) Explain memory management in Qt.

Q. What does SIGNAL() and SLOT() macro expand to?

Q. Does Qt has Garbage collection system?
Q. what is "emit", "slots", "signals"? (are they macro, keyword or function?)
Q. Have you made any custom widget yourself?
Q. What classes does Qt provides to handle XML?
Q. Difference between Dom, SAX, Readers?
Q. How do you use thread classes?
Q. What is QMutex and how do you use it?
Q. Explain Model View framework. And mention one situation where you used it.
Q. How do you communicate between threads?
Q. What is QApplication?
Q. If i create two objects of QApplication what will happen? Why shouldn't i use two?
Q. What is Q_SLOTS? why it is needed? whats the problem in "slots"?

1. where exactly we have to use this following unicode classes

   QString(),
   QByteArray(),
   QTextStream(),
   QTextCodec()

 

转载于:https://www.cnblogs.com/simonhaninmelbourne/archive/2013/04/13/3018480.html

你可能感兴趣的文章
Effective C++笔记——day01
查看>>
Leetcode题解(32)
查看>>
git删除文件
查看>>
P4302 [SCOI2003]字符串折叠
查看>>
神秘的程序员
查看>>
jS 中创建对象:
查看>>
jeecms系统使用介绍——jeecms中的内容、栏目、模型之间的关系
查看>>
UWP 设置桌面壁纸、锁屏图片
查看>>
Vue.2.0.5-事件处理器
查看>>
性能测试常用概念及计算公式
查看>>
python接口自动化测试五:乱码、警告、错误处理
查看>>
分页查询的一个帮助类
查看>>
svn批量的添加ignore
查看>>
zless轻量级样式框架
查看>>
80 mysql 如何设置 unsigned
查看>>
where 1=0的含义
查看>>
ZeroMQ接口函数之 :zmq_term - 终结ZMQ环境上下文(context)
查看>>
【杂谈】用了几千年的就是有用的吗?
查看>>
比酒量|2012年蓝桥杯B组题解析第三题-fishers
查看>>
python发送邮件
查看>>