Hi all,
I want to make s.th. like Konqueror's shortcuts for my program. Because the interface is dynamic, i don't know how much "fields" (understand input data objects) will be there, so i have to generate the shortcuts on-the-fly.
Here's an example:
//-----------------------------------------------------------------------------
void n_dv_frame
::set_accel_key( n_qt_property
* prop,
const QChar & accel
) {
int id = f_accel->findKey( seq );
if ( id == -1 )
{
id = f_accel->insertItem( seq );
}
f_accel->connectItem( id, prop, SLOT( setFocus() ) );
}
//-----------------------------------------------------------------------------
void n_dv_frame::set_accel_key( n_qt_property * prop, const QChar & accel )
{
QKeySequence seq( QString( "Alt+" ) + accel );
int id = f_accel->findKey( seq );
if ( id == -1 )
{
id = f_accel->insertItem( seq );
}
f_accel->connectItem( id, prop, SLOT( setFocus() ) );
}
To copy to clipboard, switch view to plain text mode
The problem here lies with the non-english (unicode) characters. The "property" here has a QLabel associated with it, so they become a tuple. The QLabel's text is mostly non-english. (NOT unicode, i couldn't manage my program to correctly work with totally unicode strings, i had to use QString::fromUtf8() for that). So, I transform the string from unicode to the current locale which the program is running in and display the strings. So far so good. Then I try to make a shortcut to the "property" from the text that the QLabel displays. It fails for non-english shortcuts. This is the last almost-working source. I have tried with
QKeySequence seq( ALT + UNICODE_ACCEL + accel.unicode() );
To copy to clipboard, switch view to plain text mode
but still no luck. Any hints?
Edited:
---------------------------------------------
Okay, I finally got it: it is because of the characters i am using. I need to translate them to english ones (Key_A, Key_B, etc) to work. Is this right? And if it is, how to do it?
Bookmarks