Posts

Showing posts with the label qt

Qt GLWidget how to draw text

Qt GLWidget how to draw text before I used Qt and customized my own Widget which is inherits from QGLWidget i used OpenGl in standard projects and free glut. by doing this, I used glutBitmapChracter but now in Qt there is no need to manage windows because I created customize widget with gui. so how can I draw text on the widget? if I want to include the free glut and use glutBitmapCharacter I nedd also to init the glut and im getting confused? is there any other way or do I have to use external library? Qt Docs – Asaq Jul 1 at 13:18 1 Answer 1 You are using a QGLWidget and want to draw 2D text on top of the 3D scene? glutBitmapCharacter should still work in a QGLWidget, just like other GL library code. I do not think you need to call glutInit to use the ...

Why it uses d->eventFilters.prepend(obj) not append(obj) in function(QObject::installEventFilter)

Why it uses d->eventFilters.prepend(obj) not append(obj) in function(QObject::installEventFilter) Why it uses d->eventFilters.prepend(obj) not append(obj) in function( QObject::installEventFilter ),i want to know why design it in such way.I just curious about it. d->eventFilters.prepend(obj) QObject::installEventFilter void QObject::installEventFilter(QObject *obj) { Q_D(QObject); if (!obj) return; if (d->threadData != obj->d_func()->threadData) { qWarning("QObject::installEventFilter(): Cannot filter events for objects in a different thread."); return; } // clean up unused items in the list d->eventFilters.removeAll((QObject*)0); d->eventFilters.removeAll(obj); d->eventFilters.prepend(obj); } 1 Answer 1 It's done that way because the most recently installed event filter is to be processed first, i....

QApplication::processEvents on a different thread

QApplication::processEvents on a different thread I have a couple questions. Is it possible to initialize a QApplication object on one thread and destroy it on another? Why does QApplication have to run on the same thread in which it was allocated? Is it possible to run QApplication::processEvents() on a different thread from where the QApplication object was created? Will this work if the thread to call processEvents was a non-QT thread? QApplication::processEvents() 1 Answer 1 It may be possible but Qt is not tested for it. I imagine that it's possible to hack that in - you'd need code changes. It won't ever work on MacOS, unless you're having only QCoreApplication in mind - neither the QApp.. nor QGuiApp.. supports other threads on that platform, and possibly on other platforms as well (Windows excepted). I have no idea why would you do that, though. Once the QApplication eve...

How to get QColor::greenF color value exactly between 0 and 1 instead of rounding off?

How to get QColor::greenF color value exactly between 0 and 1 instead of rounding off? I have a QColor value and I need to break it down into its RGB components between 0 and 1 with only one value after decimal point. For example: Orange color is QColor Orange color QColor color = QColor(255,128,0) qreal green = color.greenF(); qDebug() << green; //0.501960784 Whereas the green component must be 0.6 . That is, it's rgb value is (255,128,0) or (1,0.6,0). 0.6 rgb value is (255,128,0) or (1,0.6,0). How to get 0.6 instead of 0.501960784 ? 0.6 0.501960784 128/255 is not 0.6. Have you tried using 153 instead? – Angew Jul 1 at 19:57 @Angew But Orange color is 255,128,0 and '255,153,0' will be the different type of orange color. I have to map 0-255 range to 0-1 range to refle...

OpenGL Application makes Xorg leaks

OpenGL Application makes Xorg leaks I am working on a rather big Qt5/OpenGL application. Each time the application run and exit on a linux with nvidia driver, with a compositor active , nvidia-smi shows an increase of 4Mb of VRAM usage for Xorg process. My suposition would be that even if my application leaks, everything should be released when it is destroyed, but it does not seems to be the case. On this thread OpenGL GPU Memory cleanup, required?, Someone mentionned that it would not be the case if "Display list" are shared. I do not know much about OpenGL, and could not find coherent informations about this issue on the web. My objective is to understand how this could happen, where it may come from in my code and how to fix it. Note : The leaks are present in Xorg after my Aplication is stopped and no other process then Xorg and Desktop Environnement related are shown in nvidia-smi The DE I use does not matter (tested : KDE, Lxde, OpenBox, Gnome, Unity). The Linux Distri...

Is there a easy way to protect, or revert Qt source code?

Is there a easy way to protect, or revert Qt source code? I just accidentally refactored QList to QSet, and Qt faithfully did it, to all of its own sources too... (yup, that was dumb!) Thankfully my code is source controlled, I just reverted everything, would it be feasible/sensible to make a git repo for the Qt sources too? (I have the free version so I didn't think I could modify them anyway...?) Is there a hidden setting that will prevent its sources from being modifiable, to stop me from doing this again? I'm currently using the maintenance tool to install a newer version of Qt, but other than update or add/remove, there wasn't a re-install option that I could see, am I missing something? 2 Answers 2 Thankfully my code is source controlled, I just reverted everything, would it be feasible/sensible to make a git repo for the Qt sources too? (I have the free version so I didn't thi...