qt4

How to propagate keyPressEvent on different qt QMainWindow

ⅰ亾dé卋堺 提交于 2019-12-24 07:59:38
问题 I have 2 different QMainWindow, the first is the parent of the second. I want press some keys in the children windows and propagate the event in the parent. I create for everyone the function void keyPressEvent(QKeyEvent* event); but when i press key on the children the event is not propagate to the parent. Why? This is the code... //Parent class.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QKeyEvent> #include "test.h" #include <QDebug> namespace Ui { class

Does QNetworkManager get accept compressed replies by default?

廉价感情. 提交于 2019-12-24 03:43:13
问题 I am using QNetworkManager to fetch files from a server, however what I cannot figure out is if the files are compressed during the transfer with the standard gzip compression and if not how to get them to download compressed. How would I go about checking? 回答1: I just ran a quick test by adding: request.setRawHeader("Accept-Encoding", "gzip,deflate"); to the QNetworkRequest and the data returns what look compressed (because its ~20% smaller and unusable). It appears that the QNetworkManager

Creating a custom context menu in Qt

戏子无情 提交于 2019-12-24 03:39:20
问题 I'd like to create a special context menu for my application. The menu may have different shape and behaviour from the standard context menu. For example I'd like to draw them circle-shaped or with ability to right-click on a menu entry, to open another menu about that menu item. Of course, I'd like to integrate them as much as possible with the current framework, that is having action-based menu and such (but I'm not sure about what properties should have a menu to "fit" in the Qt framework)

Qt: Detecting a mousePressEvent outside of a specific QWidget

纵饮孤独 提交于 2019-12-24 03:30:21
问题 I have a widget containing multiple child objects, which the user can select by clicking them. I want to clear the current selection when the user clicks outside the widget and I'm wondering how best to detect these clicks. Some constraints: It's not really viable to eat the mousePressEvents of surrounding objects through eventFilter . If I can avoid using grabMouse() , I'd like to, because of this warning from the docs: Warning: Bugs in mouse-grabbing applications very often lock the

Efficiency of Qt Signals and Slots

与世无争的帅哥 提交于 2019-12-24 02:25:36
问题 I was browsing the methods inside of QMainWindow and noticed that some parts (such as resizeEvent and winEvent) are not implemented as signals but rather you have to inherit this class to be able to override them. My question is, how efficient are signals and slots and would it be possible to implement these types of functions as signals from which other classes can subscribe to. For instance, inside of a high performance game engine. 回答1: From what I recall, Trolltech stated that a signal

Qt4: QAbstractTableModel Drag and Drop w/o MIME

梦想的初衷 提交于 2019-12-24 02:22:13
问题 I have a class which inherits QAbstractTableModel, and holds some complex structs in a QMap. The QVariant data(QModelIndex index, ...) method just returns an enum which describes how a custom item delegate should draw the contents of a cell. I would like to implement drag and drop functionality in this model so that users can reorder these structs in the QMap, but can't quite figure our how Qt would like me to do this. All I need is to see the source and destination indices of the drag/drop

QPushButton is not changing the background-color proper

╄→尐↘猪︶ㄣ 提交于 2019-12-24 01:19:02
问题 I have a problem with a QPushButton. I use QT 4.8 and the Designer. I configured the button to be "flat" and "checkable". The button should be red if not checked and green if checked. To style the button I use a stylesheet. QPushButton:default{ background-color: red; color: red; } QPushButton:checked{ background-color: green; color: black; } Now the problem. If the button is unchecked it is gray. When I press the button he turns green like it should. I tried different other pseudo-states,

Qt4 no focus loss on clicking menubar

删除回忆录丶 提交于 2019-12-24 01:08:21
问题 I have a pyqt application where I have two QLineEdit fields which get data from a QDataWidgetMapper. I can edit the text in the fields and the change is commit on focus loss when I e.g. click in the other unselected field. But if I edit the text and then click on the menubar and there on e.g. save, I won't have a focus loss and therefore my last entered data never reaches the model. How can I get a focus loss on clicking on the menubar? 回答1: For me, connecting to the QLineEdit.editingFinished

${QT_LIBRARIES} in cmake

倖福魔咒の 提交于 2019-12-24 00:55:56
问题 ${QT_LIBRARIES} seems to turn out as "" when I do message("${QT_LIBRARIES}") and have a general suspicion that it is no being set properly. In fact it doesnt seem as if any of the attributes are being set properly by find_package(Qt4 REQUIRED). Any ideas? I have also tried find_package(Qt4 4.6.2 COMPONENTS QtCore QtGui REQUIRED ) and I know that it is finding the individual qt libraries (from cmake-gui). Thanks in advance! 回答1: You have to specify the actual Qt libraries you need, like this:

How to make an extra icon in QLineEdit like this?

…衆ロ難τιáo~ 提交于 2019-12-24 00:43:07
问题 I would like to implemented a "clean" button like the following screenshot in Qt Creator, the button dwells in QLineEdit, not a single widget Where should I start from ? 回答1: See this blog entry for a proposed solution http://blog.qt.digia.com/blog/2007/06/06/lineedit-with-a-clear-button/ Since the original link is not available anymore, I provide a new code snippet. The main idea is to add a QToolButton to the QLineEdit and position it properly. LineEdit::LineEdit(QWidget *parent) :