qt4

How to stop spacebar from triggering a focused QPushButton?

纵然是瞬间 提交于 2021-02-08 05:02:04
问题 Suppose I have a focused QPushButton : my_button = new QPushButton("Press me!", this); my_button->setFocus(); When this button is displayed, pressing Space will trigger (i.e. click) the button. I don't want this behavior. Instead, I would like Ctrl + Enter to trigger the button. How can I achieve this in Qt? (Working examples would really help as this is part of my first Qt app) 回答1: I think the best way is to do as @thuga said. The idea is to subclass the QPushButton and reimplement

How to stop spacebar from triggering a focused QPushButton?

十年热恋 提交于 2021-02-08 05:01:59
问题 Suppose I have a focused QPushButton : my_button = new QPushButton("Press me!", this); my_button->setFocus(); When this button is displayed, pressing Space will trigger (i.e. click) the button. I don't want this behavior. Instead, I would like Ctrl + Enter to trigger the button. How can I achieve this in Qt? (Working examples would really help as this is part of my first Qt app) 回答1: I think the best way is to do as @thuga said. The idea is to subclass the QPushButton and reimplement

How do i add or import pyqt and sip to Python

十年热恋 提交于 2021-02-07 20:29:47
问题 im having trouble importing this. i am a newbie so please use layman words i can follow:p. riverbank said i need sip. but there is a sip folder in the pyqt download i installed, so do i have it already? there are some related questions on this site, which lead me to try these method:.. my pyqt folder is PyQt-win-gpl-4.9.4. so i typed: sys.path.append('C:\Program Files\PyQt-win-gpl-4.9.4\sip') this adds it fine, inside the 'sip' folder, it has a bunch of folders like QtCore etc.. and ive tried

How do i add or import pyqt and sip to Python

人走茶凉 提交于 2021-02-07 20:28:18
问题 im having trouble importing this. i am a newbie so please use layman words i can follow:p. riverbank said i need sip. but there is a sip folder in the pyqt download i installed, so do i have it already? there are some related questions on this site, which lead me to try these method:.. my pyqt folder is PyQt-win-gpl-4.9.4. so i typed: sys.path.append('C:\Program Files\PyQt-win-gpl-4.9.4\sip') this adds it fine, inside the 'sip' folder, it has a bunch of folders like QtCore etc.. and ive tried

Qt: Roundoff of 12.625 by 2 returns 12.62

China☆狼群 提交于 2021-02-07 19:42:07
问题 I can't get it why the ff code returns 12.62 instead of 12.63 QDebug << QString::number(12.625, 'f', 2); and also what will be the solution for this? Currently my solution is this QDebug << QString::number(12.625 + 0.0001, 'f', 2); and it will return 12.63 . btw my OS is ubuntu 11.04 回答1: GCC uses "Round to Even" or "Banker's Rounding" as it's default mode while Visual Studio uses "Round away from Zero" From the GCC docs: Rounding This is the default mode. It should be used unless there is a

Qt Widget - how to capture just a few keyboard keys

不羁岁月 提交于 2021-02-07 14:16:49
问题 I know that with grabKeyboard() my widget is able to grab every keyboard event also if it's not focused, but what if I wanted to capture just three or four keys? I tried with an event filter http://doc.trolltech.com/3.3/qobject.html#installEventFilter but that didn't work (perhaps because I installed it like this?) class MyWidget: public QGLWidget { ... protected: bool eventFilter( QObject *o, QEvent *e ); }; bool MyWidget::eventFilter( QObject *o, QEvent *e ) { if ( e->type() == QEvent:

Qt QFileDialog - native dialogs only with static functions?

二次信任 提交于 2021-02-07 13:16:52
问题 I'm trying to simply save a file. However, I need a filename entered without a suffix to automatically get a default suffix (which setDefaultSuffix() does). I'd rather not completely lose the native save dialog just for this. exec() is not overloaded from QDialog, so it totally bypasses the native hook (ignoring the DontUseNativeDialog option even if it's false). If I disable the file overwrite warning and append the default suffix myself after the function returns, then I'd be re-opening the

Qt QFileDialog - native dialogs only with static functions?

不想你离开。 提交于 2021-02-07 13:15:56
问题 I'm trying to simply save a file. However, I need a filename entered without a suffix to automatically get a default suffix (which setDefaultSuffix() does). I'd rather not completely lose the native save dialog just for this. exec() is not overloaded from QDialog, so it totally bypasses the native hook (ignoring the DontUseNativeDialog option even if it's false). If I disable the file overwrite warning and append the default suffix myself after the function returns, then I'd be re-opening the

Qt Tray Icon Drag and Drop

余生颓废 提交于 2021-02-07 07:16:47
问题 Does anyone know if it is possible to use drag and drop with a tray icon using Qt? 回答1: I've been doing some research and here is what I have come up with: A QSystemTrayIcon cannot explicitly handle a drag/drop event. However there is a workaround based on the Spifftastic tray icon location method. You create a uniquely colored icon and place it as the icon for a brief moment and take a screenshot of it. Given that you know the color sequence for the icon, you can search through the

Qt Tray Icon Drag and Drop

强颜欢笑 提交于 2021-02-07 07:15:57
问题 Does anyone know if it is possible to use drag and drop with a tray icon using Qt? 回答1: I've been doing some research and here is what I have come up with: A QSystemTrayIcon cannot explicitly handle a drag/drop event. However there is a workaround based on the Spifftastic tray icon location method. You create a uniquely colored icon and place it as the icon for a brief moment and take a screenshot of it. Given that you know the color sequence for the icon, you can search through the