PDA

View Full Version : Building florence virtual keyboard as plug in target



nronqt
6th October 2016, 21:59
Hi there. With much effort I have tried to build a florence plug in target. My goal is to be able to use the keyboard in Qt Designer and also be able to call the keyboard when line edits receive focus. I'm trying this build in a Qt 5.5.0 with the GCC compiler on Ubuntu 14.04 distribution. I get an error that some say have to do with the code in florence using an old deprecated library or method. However I don't know how I would be able to fix this. Can anyone help me build this plug in? It will be much appreciated. Attached is a picture with the errors, warnings and the specific line with the issue. Also as advised by members of the community I'm attaching the conflicting code in between #.



void Florence::mouseMoveEvent( QMouseEvent *event )
{
if ( event->buttons() > Qt::NoButton ) {
Key *k = static_cast<Key *>( this->scene()->itemAt( this->mapToScene( event->pos() ) ) );
if ( k != this->focusKey ) {
this->autoRepeatTimer->stop();
if ( this->focusKey ) this->focusKey->hoverLeaveEvent();
this->focusKey = k;
if ( k ) {
k->hoverEnterEvent();
this->autoRepeatTimer->start( 1000 );
}
}
}
QGraphicsView::mouseMoveEvent( event );
}


The specific error is as follows:


/home/rey/Desktop/florence/qt/src/florence.cpp:147: error: no matching function for call to 'QGraphicsScene::itemAt(QPointF)'
Key *k = static_cast<Key *>( this->scene()->itemAt( this->mapToScene( event->pos() ) ) );
^


**Update: I know the itemAt is the problem. I have looked online for refactored code from other developers on places like Github to see how they fixed the problem. Still I get new errors when I try to fix the problem.

d_stranz
7th October 2016, 01:27
Also as advised by members of the community I'm attaching the conflicting code in between #.

LOL. Not exactly... read my signature block a bit more carefully.

itemAt() expects a reference to a QTransform instance as the second argument. You could try something like the following:



Key * k = static_cast< Key * >( scene()->itemAt( mapToScene( event->pos(), QTransform() ) ) );


This uses a default constructed (i.e. identity matrix) QTransform, which may or may not be the right transformation in this case. It will get you past the compilation error.

Note that using "this->" in member functions is totally unnecessary; in a member function it is assumed that the current instance ("this") is to be used when calling member functions of the same class.

nronqt
7th October 2016, 15:54
Following your advise, I:
#include <QTransform>

The new piece of code looks like this:


void Florence::mouseMoveEvent( QMouseEvent *event )
{
if ( event->buttons() > Qt::NoButton ) {
Key *k = static_cast<Key *>( this->scene()->itemAt( this->mapToScene( event->pos() , QTransform() ) ) );
if ( k != this->focusKey ) {
this->autoRepeatTimer->stop();
if ( this->focusKey ) this->focusKey->hoverLeaveEvent();
this->focusKey = k;
if ( k ) {
k->hoverEnterEvent();
this->autoRepeatTimer->start( 1000 );
}
}
}
QGraphicsView::mouseMoveEvent( event );
}


The new error I get is as follows:


/home/rey/Desktop/florence/qt/src/florence.cpp:148: error: no matching function for call to 'Florence::mapToScene(QPoint, QTransform)'
Key *k = static_cast<Key *>( this->scene()->itemAt( this->mapToScene( event->pos() , QTransform() ) ) );
^

nronqt
7th October 2016, 18:13
I looked at the Makefile on the florence directory I have been trying to build and it was build with Qt 5.2. Since I have had no luck in building the florence plug in with that file, I decided to try the same build steps I found in this same file, instead with the latest florence from [ https://sourceforge.net/projects/florence/?source=directory ]. Now again I'm having issues compiling and building the application.

The error has to do with [ #include <gtk/gtk.h> ] and is as follows:
#
/home/rey/Desktop/florence-0.6.3/src/status.h:31: error: gtk/gtk.h: No such file or directory
#include <gtk/gtk.h>
^
#

I have tried all of these to make sure the header files are within my ubuntu system:
#
sudo apt-get install libgtk2.0-dev
sudo apt-get install libgtk2-dev
sudo apt-get install libgtk3.0-dev
sudo apt-get install libgtk3-dev
sudo apt-get install gtk+2.0-dev
sudo apt-get install gtk+3.0-dev
#
I have also ran pacman with:
#
pacman -Ql gtk3
#
as suggested in another forum to make sure the libraries are there. It ran.

After doing all of this and opening the src.pro with all the files florence needs I still could not compile and build the application. I think my issue could be that I ran the wrong qmake command, as in it was incomplete. The command I ran was:
#
qmake -project
#
directly when I was in the src directory within florence-0.6.3 (the last one I downloaded from sourceforge.net). And then it build for me the src.pro which I could use to import the whole project in Qt Creator 5.5.

Here are all the options that I have. I'm still learning linux so I don't fully understand what I must do to get the right .pro file if that's the actual problem.
#
rey@rey-VirtualBox:~/Desktop/florence-0.6.3/src$ qmake
Usage: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake [mode] [options] [files]

QMake has two modes, one mode for generating project files based on
some heuristics, and the other for generating makefiles. Normally you
shouldn't need to specify a mode, as makefile generation is the default
mode for qmake, but you may use this to test qmake on an existing project

Mode:
-project Put qmake into project file generation mode
In this mode qmake interprets files as files to
be built,
defaults to *; *; *; *.ts; *.xlf; *.qrc
Note: The created .pro file probably will
need to be edited. For example add the QT variable to
specify what modules are required.
-makefile Put qmake into makefile generation mode (default)
In this mode qmake interprets files as project files to
be processed, if skipped qmake will try to find a project
file in your current working directory

Warnings Options:
-Wnone Turn off all warnings; specific ones may be re-enabled by
later -W options
-Wall Turn on all warnings
-Wparser Turn on parser warnings
-Wlogic Turn on logic warnings (on by default)
-Wdeprecated Turn on deprecation warnings (on by default)

Options:
* You can place any variable assignment in options and it will be *
* processed as if it was in [files]. These assignments will be parsed *
* before [files]. *
-o file Write output to file
-d Increase debug level
-t templ Overrides TEMPLATE as templ
-tp prefix Overrides TEMPLATE so that prefix is prefixed into the value
-help This help
-v Version information
-after All variable assignments after this will be
parsed after [files]
-norecursive Don't do a recursive search
-recursive Do a recursive search
-set <prop> <value> Set persistent property
-unset <prop> Unset persistent property
-query <prop> Query persistent property. Show all if <prop> is empty.
-cache file Use file as cache [makefile mode only]
-spec spec Use spec as QMAKESPEC [makefile mode only]
-nocache Don't use a cache file [makefile mode only]
-nodepend Don't generate dependencies [makefile mode only]
-nomoc Don't generate moc targets [makefile mode only]
-nopwd Don't look for files in pwd [project mode only]
rey@rey-VirtualBox:~/Desktop/florence-0.6.3/src$ ls
controller.c layoutreader.c service.h tools.h
controller.h layoutreader.h settings.c trace.c
florence-1.0.pc.in lib settings.h trace.h
florence.c main.c settings-window.c trayicon.c
florence.h Makefile settings-window.h trayicon.h
florence.server.in.in Makefile.am src.pro.user view.c
fsm.c Makefile.in status.c view.h
fsm.h menu.c status.h xkeyboard.c
keyboard.c menu.h style.c xkeyboard.h
keyboard.h ramble.c style.h
key.c ramble.h system.h
key.h service.c tools.c
rey@rey-VirtualBox:~/Desktop/florence-0.6.3/src$ qmake
Usage: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake [mode] [options] [files]

QMake has two modes, one mode for generating project files based on
some heuristics, and the other for generating makefiles. Normally you
shouldn't need to specify a mode, as makefile generation is the default
mode for qmake, but you may use this to test qmake on an existing project

Mode:
-project Put qmake into project file generation mode
In this mode qmake interprets files as files to
be built,
defaults to *; *; *; *.ts; *.xlf; *.qrc
Note: The created .pro file probably will
need to be edited. For example add the QT variable to
specify what modules are required.
-makefile Put qmake into makefile generation mode (default)
In this mode qmake interprets files as project files to
be processed, if skipped qmake will try to find a project
file in your current working directory

Warnings Options:
-Wnone Turn off all warnings; specific ones may be re-enabled by
later -W options
-Wall Turn on all warnings
-Wparser Turn on parser warnings
-Wlogic Turn on logic warnings (on by default)
-Wdeprecated Turn on deprecation warnings (on by default)

Options:
* You can place any variable assignment in options and it will be *
* processed as if it was in [files]. These assignments will be parsed *
* before [files]. *
-o file Write output to file
-d Increase debug level
-t templ Overrides TEMPLATE as templ
-tp prefix Overrides TEMPLATE so that prefix is prefixed into the value
-help This help
-v Version information
-after All variable assignments after this will be
parsed after [files]
-norecursive Don't do a recursive search
-recursive Do a recursive search
-set <prop> <value> Set persistent property
-unset <prop> Unset persistent property
-query <prop> Query persistent property. Show all if <prop> is empty.
-cache file Use file as cache [makefile mode only]
-spec spec Use spec as QMAKESPEC [makefile mode only]
-nocache Don't use a cache file [makefile mode only]
-nodepend Don't generate dependencies [makefile mode only]
-nomoc Don't generate moc targets [makefile mode only]
-nopwd Don't look for files in pwd [project mode only]
rey@rey-VirtualBox:~/Desktop/florence-0.6.3/src$
#

Please if someone knows how I can build this plug in correctly instruct me as to how I should proceed. Thanks in advance. I'm thinking of trying it with Qt Creator 5.2, but I would rather fix the errors and use the latest software than to stick to having to use old deprecated libraries which could affect performance.