qt4

How can I efficiently expand an entire subtree of a QTreeView?

人走茶凉 提交于 2020-02-05 13:57:15
问题 EDIT: it turns out that the root performance problem was a size-to-fit function attached to the expanded() signal, so I'm going to accept the first answer and delete this question for being misleading. Note: I'm asking this question so I can provide an answer for it (and maybe get a better answer). The solution is not intuitive. MacOS builds of Qt may have a way for the user to expand an entire QTreeView subtree (there was an open bug for it) but non-MacOS builds definitely do not. I am

How to hide mouse pointer in Qt app at startup?

情到浓时终转凉″ 提交于 2020-02-05 03:47:45
问题 I have a small Qt application that displays an image to the screen (more on that including source code here: Qt: Modify alpha channel transparency of a windowless QLabel). By default, Qt is inserting a mouse pointer on top of my image. For my application, I do not need any physical user interaction with Qt and thus have no need for a mouse pointer. I have used the following code to hide the mouse pointer, but it only hides the mouse once the mouse has been physically moved, and only within

Save/open dialog localization in Qt

你。 提交于 2020-02-03 13:34:01
问题 I try to set localization for standard save or open dialogs, but everything except window caption remains English. I use Qt 4.7.4 and KDE of the same version. The following example application: #include <QApplication> #include <QFileDialog> #include <QTranslator> #include <QLibraryInfo> #include <QDebug> int main(int argc, char **argv) { QApplication app(argc,argv); QTranslator qTranslator; QString transPath=QLibraryInfo::location(QLibraryInfo::TranslationsPath); qTranslator.load("qt_ru"

How to Create OpenGL 3 Context with Qt 4?

霸气de小男生 提交于 2020-02-03 10:19:19
问题 I would like to learn graphics programming with OpenGL. And since I will just start learning it I decided to learn the new/OpenGL3 way of doing things.As far as I can see one has to create an OpenGL 3 context for this (Core profile in the new OpenGL 3.2 if I understand this correctly). Well I thought about using Qt for this, currently using version 4.5.2, since I know it already and like it and it supports creating the OpenGL widget. What I have the problem with is that it looks like the

How to Create OpenGL 3 Context with Qt 4?

匆匆过客 提交于 2020-02-03 10:19:13
问题 I would like to learn graphics programming with OpenGL. And since I will just start learning it I decided to learn the new/OpenGL3 way of doing things.As far as I can see one has to create an OpenGL 3 context for this (Core profile in the new OpenGL 3.2 if I understand this correctly). Well I thought about using Qt for this, currently using version 4.5.2, since I know it already and like it and it supports creating the OpenGL widget. What I have the problem with is that it looks like the

How to Create OpenGL 3 Context with Qt 4?

淺唱寂寞╮ 提交于 2020-02-03 10:18:09
问题 I would like to learn graphics programming with OpenGL. And since I will just start learning it I decided to learn the new/OpenGL3 way of doing things.As far as I can see one has to create an OpenGL 3 context for this (Core profile in the new OpenGL 3.2 if I understand this correctly). Well I thought about using Qt for this, currently using version 4.5.2, since I know it already and like it and it supports creating the OpenGL widget. What I have the problem with is that it looks like the

How can I disable Alt + F4 window closing using Qt?

你离开我真会死。 提交于 2020-01-30 18:53:27
问题 I've disabled X button in Qt from my dialog using this line: myDialog->setWindowFlags(Qt::Dialog | Qt::Desktop) but I couldn't detect Alt + F4 using this code: void myClass::keyPressEvent(QKeyEvent *e) { if ((e->key()==Qt::Key_F4) && (e->modifiers()==Qt::AltModifier)) doSomething(); } what should I do to detect Alt + F4 or disable it in Qt? 回答1: Pressing Alt+F4 results in a close event being sent to your top level window. In your window class, you can override closeEvent() to ignore it and

How to force calling of QWidget::paintEvent() when its hovered by other window?

帅比萌擦擦* 提交于 2020-01-30 13:15:10
问题 I have occured a problem: I'm writing a widget, which displays current date's day number. It's like a button, but it's not derived from QPushButton class. Just from QWidget . So I reimplemented enterEvent() , leaveEvent() , mousePressEvent() , mouseReleaseEvent() . I call update() inside these methods and widget has realistic button behavior ( paintEvent() is reimplemented too). But when I change system date and hover that widget with other window, my widget doesn't calls paintEvent() and

Dropping a file from outside an application into QTableView

☆樱花仙子☆ 提交于 2020-01-30 11:56:26
问题 I have a QTableView and I'd like to be able to drop an image file from outside the application onto a row and upon this event it needs to identify which row it was dropped on, do things with the file (copy to a directory, resize, add to db, ...) and finally update a column in the table that this item/row now has an image file associated to it. I've figured out that I can inherit from e.g. QTableView, re-implement dropEvent(QDropEvent*), I could then call QDropEvent::pos() inside the member

Qt - How to convert from QObject to UI elements?

╄→гoц情女王★ 提交于 2020-01-30 06:15:08
问题 I am working in Qt 4.7, and I have a QWidget object in my dialog. I need to go through each of the children and extract the current text into a QStringList. Every other object is a QCheckBox, and the rest are QComboBoxes (I would just need the text portion of both). So far the only way I could think of to do this would be to use the children() function to get them as QObject*'s and cast them, like this: QStringList textlist; for(int i = 0; i < ui->myWidget->children().size(); i++) { if(i % 2