mkottman / lqt Goto Github PK
View Code? Open in Web Editor NEWLua bindings for Qt4 by Mauro Iazzi
Home Page: http://code.google.com/p/lqt/
License: MIT License
Lua bindings for Qt4 by Mauro Iazzi
Home Page: http://code.google.com/p/lqt/
License: MIT License
QModelIndex QAbstractItemModel::createIndex ( int row, int column, void * ptr = 0 ) const [protected]
Creates a model index for the given row and column with the internal pointer ptr.
QModelIndex QAbstractItemModel::createIndex ( int row, int column, quint32 id ) const [protected]
Creates a model index for the given row and column with the internal identifier, id.
I built lqt successfully on macosx 10.6 but lua crashes as soon as I load the qtgui library with the following error:
lua(39856,0x7fff70745ca0) malloc: *** error for object 0x1057590a0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap
I found that if I stop the garbage collector (collectgarbage'stop') first I can run successfully all the training examples, but lua still crashes on exit. I will try to find more info about what might cause this crash.
I also found that I am not the only one with this problem: http://lua-list.2524044.n2.nabble.com/lqt-on-OS-X-td4992034.html#a6415247 has it as well.
Best regards
Charles
EDIT: the problem is not only qtgui, as the test 'virt_test.lua' also crashes in the same way, even though it only uses qtcore. Please tell me if there is anything I can do to help solve this issue.
EDIT #2: I just tried the old lqt version from repo.or.cz, and it works! Well, as long as I use the lua interpreter included with it, as soon as I use mine (which is the same 5.1.4 version), it crashes on exit with the same error.
I'd really like to understand what is going on...
QModelIndex QAbstractItemView::moveCursor ( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) [pure virtual protected]
Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction and keyboard modifiers specified by modifiers.
In the base class this is a pure virtual function.
The Phonon library is not compiled because it is commented in CMakeLists.txt due to various dependency problems.
(This is fairly high on my personal wishlist since it would mean lqt would be a totally viable option to develop advanced media players)
I'd like to record audio in my program, particularly using QAudioInput.
Reckon you can add support for it?
I can't seem to find some defines anywhere in the library
Eg, QWIDGETSIZE_MAX
I was wondering how do you do custom slots?
void QAbstractItemView::setState ( State state ) [protected]
Sets the item view's state to the given state.
This is a known problem and caused by changes in Qt 4.8
It used to work fine prior to that.
Hey guys,
hopefully someone will see this post after the latest contribution to this project is a little back-dated :(
At first, I want to make clear what I have achieved so far:
I checked the qmake-generated files "Makefile", "Makefile.debug" and "Makefile.release" so often, I cannot even count my attempts. I changed the "qtgui.pro"-file back and forth, but nothing seemed to work.
At first I had the idea that - as it often is - a library wasn't included correctly. Each of the unresolved externals (there are about 1500 !!!! of them) has a pefix 'Q' in front, like:
qtgui_merged_build.obj:-1: Fehler: LNK2001: unresolved external symbol "public: virtual bool __thiscall QWizard::winEvent(struct tagMSG *,long *)" (?winEvent@QWizard@@UAE_NPAUtagMSG@@paj@Z
So I assumed it would be one of the Qt-libraries. But the Makefile has the correct path to the library directory of Qt (in my case "E:/Qt/4.6.3/lib") and QtCore.lib as well as QtGui.lib are included. I have also verified that the debug-libs are only included in Makefile.debug and that release-libs are only included in Makefile.release.
As you can see, I am using Qt Version 4.6.3 which has not been tested until now (this is at least what the documentation says ... ). Could this be an issue? I have checked some functions that have been declared as "unresolved" whether they are exported by the QtGui.dll and - surprise, surprise - they are indeed, so this usually can't be the problem here, can it?
I am developing on Windows 7 x64 platform using Visual Studio 2005th "nmake"-tool and the cl-compiler.
If anyone can help me getting rid of this issue, please do not hesitate replying to my post. Any help will be appreciated. If some kind of information is missing, please let me know and I try to update my post.
void QHeaderView::sectionCountChanged ( int oldCount, int newCount ) [signal]
This signal is emitted when the number of sections changes, i.e., when sections are added or deleted. The original count is specified by oldCount, and the new count by newCount.
Hi, I use QUiLoader like this:
local loader = QUiLoader.new()
local uifile = QFile.new( "main.ui" )
uifile:open( { 'ReadOnly' } )
local mainWidget = loader:load( uifile )
w1 = mainWidget:findChild( "MyPushButton" )
widget is loaded, isWidgetType() returns true, but now both approaches described in examples for signal/slots and events seem not work for w1.
i.e. app crashes after this:
w1:__addmethod( "test()", function() print(1) end )
w1:connect( "2clicked()", w1, "1test()" )
with error: bad argument #3 to 'connect' (no such receiver method: 'test()')
( i dont see test() in methods list after __addmethod)
function w1:closeEvent( e ) print(1) end
this one is just silently passing with no result for widget's behaviour. Am I doing something wrong or do those approaches work only with .new() created widgets?
p.s. as a workaround I have to create new empty QWidget and create slots for it - in this case all works fine
void QAbstractItemView::closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint ) [virtual protected slot]
Closes the given editor, and releases it. The hint is used to specify how the view should respond to the end of the editing operation. For example, the hint may indicate that the next item in the view should be opened for editing.
Hi.
Is it possible to call the base class method from an overloaded virtual method somehow? Such as,
foo = QTextEdit()
function foo:keyPressEvent(e)
-- do something
super.keyPressEvent(e)
end
This would be necessary for overloading some event handlers.
Also, binding the global namespace enums somehow would be useful. Such as,
function foo:keyPressEvent(e)
if e:key() == Qt.Key_Enter then
-- enter was pressed
end
end
hi - I'm getting the following error after 'make'
.......
Linking CXX shared module lib/qtsvg.so
[ 69%] Built target qtsvg
Scanning dependencies of target generate_qtuitools_xml
[ 69%] Generating XML: running cpptoxml on qtuitools
Error: wether 'QtUiTools' nor '/Library/Frameworks/QtCore.framework/QtUiTools/QtUiTools' or '/Library/Frameworks/QtUiTools.framework/Headers/QtUiTools' found
make[2]: *** [CMakeFiles/generate_qtuitools_xml] Error 1
make[1]: *** [CMakeFiles/generate_qtuitools_xml.dir/all] Error 2
make: *** [all] Error 2
any idea ?!
QList QTableWidget::selectedRanges () const
Returns a list of all selected ranges.
QModelIndexList QAbstractItemView::selectedIndexes () const [virtual protected]
This convenience function returns a list of all selected and non-hidden item indexes in the view. The list contains no duplicates, and is not sorted.
Hi. I was using LQT a while back, however, there was a number of things lacking, operator overloading and templates among others. This is added in your version I saw.
However, what about binding functions (not just methods) ? Is that something you are planning to add support for? That would really make this a versatile library. Im using it for binding non-lqt code.
You version of LQT is that a clone of the latest in the original repository? Are you syncing with that one?
Anyway, thanks for the addons, and keep up the good work. Marco is indicating that he does not have much time for supporting LQT for now.
void QAbstractItemView::commitData ( QWidget * editor ) [virtual protected slot]
Commit the data in the editor to the model.
The below segfaults for me; it works if I do scene:addText("hi",QFont())
instead
require "qtcore"
require "qtgui"
local app = QApplication(1 + select('#', ...), {arg[0], ...})
local scene = QGraphicsScene()
scene:addText("hi")
hi
i built lqt ok on ubuntu (11.4)
but when i run it i just get a segfault :(
running through gdb i get
Starting program: /usr/local/bin/lua test.lua
[Thread debugging using libthread_db enabled]
Cannot find new threads: generic error
but im not sure that's related to lqt
any ideas ?
Hi, I notice that there is no QtSql binding, is this because there already exist a LuaSQL ?
Thanks.
I'm not sure if this is a problem or it is just not clear to me how to do this. I'm trying to handle some keypresses to a QListWidget, but the problem I have is:
Any ideas? Is this possible already or are these functions not implemented yet?
QList<QMdiSubWindow *> QMdiArea::subWindowList ( WindowOrder order = CreationOrder ) const
Returns a list of all subwindows in the MDI area. If order is CreationOrder (the default), the windows are sorted in the order in which they were inserted into the workspace. If order is StackingOrder, the windows are listed in their stacking order, with the topmost window as the last item in the list. If order is ActivationHistoryOrder, the windows are listed according to their recent activation history.
Specifically, you can create objects in threads other than the loader, but you cannot then connect their signals to anything, or strange error messages from QCoreApplication::exec or QCoreApplication::processEvents (depending on which one your mainloop is using) will result.
Note that you can still call methods on the object from other threads, and there's no requirement that app.exec() be called from the same thread that created the object - but if the object itself is not created in the same thread that called require "qtcore", sadness occurs.
Here's a test case:
require "qtcore"
require "qtgui"
local app = QApplication(1, arg)
local window
coroutine.resume(coroutine.create(function()
window = QPushButton("click me")
end))
window:connect("2clicked()", print)
window:show()
app.exec()
--
-- output: QApplication::exec(QPushButton*): incorrect or extra arguments, expecting: .
The expected output is a bunch of "userdata" from the connected print().
Rearranging the code so that the requires of qtcore are in a separate coroutine and the creation of the QPushButton is in main results in a different but no less odd error message:
coroutine.resume(coroutine.create(function()
require "qtcore"
require "qtgui"
end))
local app = QApplication(1, arg)
local window
window = QPushButton("click me")
window:connect("2clicked()", print)
window:show()
app.exec()
--
-- output: attempt to call a nil value
Moving everything into main, or everything into the same coroutine, works fine. (I don't know what happens if you require "qtcore" from one thread and "qtgui" from a different one.)
Based on this behaviour, I suspect that when loaded, lqt is remembering the lua_State * that loaded it and is sometimes interacting with that stack even when it should be interacting with the stack that it was called from, but honestly I'm not even sure where to start debugging this, let alone writing a patch.
I'm working with a QImage and would appriciate a way to work with the raw uchar *
As a note: I am working in luajit, and using the ffi would be great!
If you could just give me a userdata (eg, img:bits() ) I can use ffi.cast
Hello again,
Would it be much trouble to add Lua bindings for the QScintilla component? If you can write me a short tutorial in the Wiki I would love to do it myself and contribute back to you.
Thanks.
Inside a paintEvent I'm doing: (s1 and t1 are of type QRectF; im is of type QImage)
local painter = QPainter ( self )
print("A",t1:x(),t1:width(),t1:y(),t1:height(),s1:x(),s1:width(),s1:y(),s1:height())
painter:drawImage ( t1 , im , s1 )
print("B")
Output before segfault is:
A 575 65 0 480 0 65 0 480
Output from valgrind:
==3738== Invalid read of size 2
==3738== at 0x935F180: QTransform::type() const (in /usr/lib/libQtGui.so.4.8.2)
==3738== by 0x937C94F: ??? (in /usr/lib/libQtGui.so.4.8.2)
==3738== by 0x930959C: QPainter::drawImage(QRectF const&, QImage const&, QRectF const&, QFlagsQt::ImageConversionFlag) (in /usr/lib/libQtGui.so.4.8.2)
==3738== by 0x11289FA0: lqt_bind_35768(lua_State_) (in /usr/lib/lua/5.1/qtgui.so)
==3738== by 0x1128E06E: lqt_dispatcher_drawImage_35269(lua_State_) (in /usr/lib/lua/5.1/qtgui.so)
==3738== by 0x44E7E5: ??? (in /usr/bin/luajit-2.0.0-beta10)
==3738== by 0x44342F: lua_pcall (in /usr/bin/luajit-2.0.0-beta10)
==3738== by 0x1111C049: lqt_shell_QWidget::paintEvent(QPaintEvent_) (in /usr/lib/lua/5.1/qtgui.so)
==3738== by 0x9209641: QWidget::event(QEvent_) (in /usr/lib/libQtGui.so.4.8.2)
==3738== by 0x111198F0: lqt_shell_QWidget::event(QEvent_) (in /usr/lib/lua/5.1/qtgui.so)
==3738== by 0x91B9F7B: QApplicationPrivate::notify_helper(QObject_, QEvent_) (in /usr/lib/libQtGui.so.4.8.2)
==3738== by 0x91BE3F9: QApplication::notify(QObject_, QEvent*) (in /usr/lib/libQtGui.so.4.8.2)
==3738== Address 0x118 is not stack'd, malloc'd or (recently) free'd
QTabBar * QTabWidget::tabBar () const [protected]
Returns the current QTabBar.
void QAbstractItemView::setSelection ( const QRect & rect, QItemSelectionModel::SelectionFlags flags ) [pure virtual protected]
Applies the selection flags to the items in or touched by the rectangle, rect.
When implementing your own itemview setSelection should call selectionModel()->select(selection, flags) where selection is either an empty QModelIndex or a QItemSelection that contains all items that are contained in rect.
I'm on windows, and I used pre-compiled package and the dlls I compiled myself, I can make it work when I use:
require 'qtcore'
require 'qtgui'
but if I only write:
require 'qtgui'
the lua.exe crashed, and gdb says there is a SIGSEGV in luaS_newstr, what's the matter?
Well behaved lua modules should not set globals;
Please fix lqt so it no longer does.
For compatability, older apps can:
local function shallowcopy ( dst , ... )
for i , src in ipairs({...}) do
for k , v in pairs ( src ) do
dst [ k ] = v
end
end
return dst
end
local Qt = shallowcopy ( {} , require"qtcore" , require"qtgui" , )
setmetatable(_G,{__index=Qt} )
Hi. Im trying to use lqt to bind non QT code. I guess this is a general lqt question, but as Mauro is not spending much time on LQT recently I thought I might pop the question here, especially as it also has to do with binding operators, which you have been working on.
Given these (simplified) class declarations:
namespace N
{
template <typename T>
class Vec3T
{
public:
//typedef T Type;
// Type _v[3];
inline Vec3T() {
}
/**
Equality test
*/
inline bool operator == ( const Vec3T& v ) const {
return true;
}
/** Binary vector subtract. */
inline const Vec3T operator - ( const Vec3T& rhs ) const {
return Vec3T( );
}
/** Unary vector subtract. */
inline Vec3T& operator -= ( const Vec3T& rhs ) {
return *this;
}
/** Negation operator. Returns the negative of the Vec3T. */
inline const Vec3T operator - () const {
return Vec3T ( );
}
};
} // end of namespace N
namespace N
{
typedef Vec3T<double> Vec3;
class Test {
public:
Test(N::Vec3 v);
N::Vec3 doIt();
};
} // end of namespace N
We can see in the generated XML file that:
<FunctionDefinition id="_6" name="operator==" scope="N::Vec3T<T>" context="N::Vec3T<T>" fullname="N::Vec3T<T>::operator=="
It is using the base definition, not the alias.
The class N::Vec3T<double>
nor N::Vec3
is bound to any interface in the generated cpp file.
The class N::Test
is bound, but all methods containing Vec3 is skipped.
If I change template <T> class Vec3T
to class Vec3 {}
, then it works.
So is this part of your ideas of getting templated classes to be exported?
At some point I managed to get the Vec3 class to be exported, but ended up with lots of problems, because methods were defined:
class C {
...
fooMethod(Vec3 val);
}
Was bound as:
::fooMethod( Vec3T<double> arg1)
instead of ::fooMethod( N::Vec3 arg1)
which in some cases caused some problems with namespaces, because it did not add the full namespace for this class.
Also, the negation operator did not work:
It resulted in the following code:
static int lqt_bind_11 (lua_State *L) {
int oldtop = lua_gettop(L);
N::Vec3T* self = static_cast<N::Vec3T*>(lqtL_toudata(L, 1, "N.Vec3T*"));
if (NULL==self) {
lua_pushfstring(L, "Instance of %s has already been deleted in:\n", "N::Vec3T");
lqtL_pushtrace(L);
lua_concat(L, 2);
lua_error(L);
}
N::Vec3T const ret = *self -(); <<< Not really valid code. >>>>
lua_settop(L, oldtop);
luaL_checkstack(L, 1, "cannot grow stack for return value");
lqtL_copyudata(L, &ret, "N.Vec3T*");
return 1;
}
Are you actively working on your LQT branch now or is it "put to sleep"??
I think its an excellent piece of software, but it of course need some fixing here and there, as always :-)
void QAbstractItemView::startDrag ( Qt::DropActions supportedActions ) [virtual protected]
Starts a drag by calling drag->exec() using the given supportedActions.
void QTabWidget::setTabBar ( QTabBar * tb ) [protected]
Replaces the dialog's QTabBar heading with the tab bar tb. Note that this must be called before any tabs have been added, or the behavior is undefined.
void QTabWidget::setTabBar ( QTabBar * tb ) [protected]
Replaces the dialog's QTabBar heading with the tab bar tb. Note that this must be called before any tabs have been added, or the behavior is undefined.
State QAbstractItemView::state () const [protected]
Returns the item view's state.
QList QNetworkInterface::allInterfaces () [static]
Returns a listing of all the network interfaces found on the host machine.
QTabBar * QTabWidget::tabBar () const [protected]
Returns the current QTabBar.
This is a small crash case, from Qt 4.8.1
template <typename T> struct QConcatenable {}; template <typename A, typename B> class QStringBuilder { private: typedef QConcatenable<QStringBuilder<A, B> > Concatenable; typedef typename Concatenable::ConvertTo ConvertTo; };
It seems that codemodel.cpp in parser has some issue in findItem, when it find a typedef in middle of a qualified name, it don't resolve it, but ignore it. so typedef ...::ConvertTo ConvertTo cause a dead loop in resolveType func, makes stack overflow :-(
QList<QTreeWidgetItem *> QTreeWidget::findItems ( const QString & text, Qt::MatchFlags flags, int column = 0 ) const
I'm trying to the use qtsql module. I'm getting the error when I try to use:
QSqlDatabase.addDatabase("QMYSQL")
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
But I definitely have a libqsqlmysql.dylib available. Do I need to compile another mysql driver for lqt? Any help or hints will be highly appreciated.
QList<QMdiSubWindow *> QMdiArea::subWindowList ( WindowOrder order = CreationOrder ) const
Returns a list of all subwindows in the MDI area. If order is CreationOrder (the default), the windows are sorted in the order in which they were inserted into the workspace. If order is StackingOrder, the windows are listed in their stacking order, with the topmost window as the last item in the list. If order is ActivationHistoryOrder, the windows are listed according to their recent activation history.
The build fails on a stock Ubuntu 10.04 LTS (Lucid Lynx) system with an error message about EasingCurve not being a member of QVariant. I first tried the build on a Ubuntu 10.10 system, it worked fine and I was able to run some tests on that platform.
Here's the relevant build output on the 10.04 system:
[ 15%] Built target cpptoxml
[ 15%] Generating XML: running cpptoxml on qtcore
[ 15%] Built target generate_qtcore_xml
[ 15%] Generating binding code with Lua
[ 16%] Built target generate_qtcore_cpp
[ 17%] Generating qtcore_src/moc_qtcore_slot.cxx
Scanning dependencies of target qtcore
[ 18%] Building CXX object CMakeFiles/qtcore.dir/qtcore_src/qtcore_merged_build.cpp.o
In file included from /usr/local/jgraves/lua/lqt/build/qtcore_src/qtcore_merged_build.cpp:179:
/usr/local/jgraves/lua/lqt/build/qtcore_src/qtcore_meta_QString.cpp: In function 'int lqt_bind_3049(lua_State*)':
/usr/local/jgraves/lua/lqt/build/qtcore_src/qtcore_meta_QString.cpp:1610: warning: format not a string literal and no format arguments
[ 18%] Building CXX object CMakeFiles/qtcore.dir/common/lqt_qt.cpp.o
/usr/local/jgraves/lua/lqt/common/lqt_qt.cpp: In function 'int lqtL_qvariant_value(lua_State*)':
/usr/local/jgraves/lua/lqt/common/lqt_qt.cpp:455: error: 'EasingCurve' is not a member of 'QVariant'
In file included from /usr/include/qt4/QtCore/qvariant.h:48,
from /usr/include/qt4/QtCore/QVariant:1,
from /usr/local/jgraves/lua/lqt/common/lqt_qt.hpp:8,
from /usr/local/jgraves/lua/lqt/common/lqt_qt.cpp:1:
/usr/include/qt4/QtCore/qmetatype.h: In static member function 'static int QMetaTypeId2<T>::qt_metatype_id() [with T = QEasingCurve]':
/usr/include/qt4/QtCore/qmetatype.h:210: instantiated from 'int qMetaTypeId(T*) [with T = QEasingCurve]'
/usr/include/qt4/QtCore/qvariant.h:459: instantiated from 'void qVariantSetValue(QVariant&, const T&) [with T = QEasingCurve]'
/usr/include/qt4/QtCore/qvariant.h:525: instantiated from 'void QVariant::setValue(const T&) [with T = QEasingCurve]'
/usr/local/jgraves/lua/lqt/common/lqt_qt.cpp:336: instantiated from here
/usr/include/qt4/QtCore/qmetatype.h:200: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<QEasingCurve>'
make[2]: *** [CMakeFiles/qtcore.dir/common/lqt_qt.cpp.o] Error 1
make[1]: *** [CMakeFiles/qtcore.dir/all] Error 2
make: *** [all] Error 2
Any method that returns "a QSomething* or NULL" - such as QMenu::actionAt() or QGraphicsScene::itemAt() - will, in the latter case, return a boxed NULL pointer rather than nil.
Reproduction:
require "qtcore"
require "qtgui"
local app = QApplication(1, arg)
local menu = QMenu("test")
local action = menu:actionAt(QPoint(0,0))
print(action) -- we haven't added any actions, so actionAt() should return NULL
print(action.__type)
print(action:menu()) -- follows the null pointer into oblivion
This is expected to output "nil" and then raise a nil-value-index error; instead it outputs "userdata", "QAction*", and then raises an "instance already deleted" error.
Simple fix:
--- a/common/lqt_common.cpp
+++ b/common/lqt_common.cpp
@@ -438,6 +438,12 @@ void lqtL_unregister (lua_State *L, const void *p) {
void lqtL_pushudata (lua_State *L, const void *p, const char *name) {
bool already = false;
+
+ if (p == NULL) {
+ lua_pushnil(L); // (1)
+ return;
+ }
+
lqtL_ensurepointer(L, p); // (1)
if (lua_getmetatable(L, -1)) {
// (2)
QList<QMdiSubWindow *> QMdiArea::subWindowList ( WindowOrder order = CreationOrder ) const
Returns a list of all subwindows in the MDI area. If order is CreationOrder (the default), the windows are sorted in the order in which they were inserted into the workspace. If order is StackingOrder, the windows are listed in their stacking order, with the topmost window as the last item in the list. If order is ActivationHistoryOrder, the windows are listed according to their recent activation history.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.