• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

QScintilla - zooming with Ctrl + Mouse wheel

Status
Not open for further replies.
Level 19
Joined
Jul 14, 2011
Messages
875
Is there any option to enable zooming with Ctrl and the Mouse wheel? I tried searching but I couldnt find it, and it seems to be disabled by default.

I have already done the lexer and some other stuff, so its not like it aint working at all.

I am using Qt5 and Qscintilla 2.9 (with Qt Creator). It did work when I was using scintilla in Win32 and PyQt (was some time ago, but I believe it was 4).

If you need anymore info, please tell me and thanks in advance!
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
As far as I can tell from looking at the API documentation, you need to call QsciScintilla::standardCommands, then QsciCommandSet::commands on the returned object, then loop over the list and call QsciCommand::command for each iterated object until you find QsciCommand::Command::ZoomIn/ZoomOut, and finally call QsciCommand::setKey with whatever you want.
I am assuming that a bitwise OR would be needed to combine a control character, however I don't see anywhere an actual list of the binding names, so I can't tell what the one for the mouse scroll would be.

However, a further look at search results gives a better solution using QShortcut.
You can use this with QsciScintilla::zoomIn/zoomOut.
 
Level 19
Joined
Jul 14, 2011
Messages
875
Thanks! I guess I wasnt searching hard enough. I'll try it as soon as I can!

EDIT: Well, it seems that there is no ID for mouse wheel scroll, and both solutions require that. What I did is handle the mouse wheel event in the QMainWindow itself, which seems to be working just fine.
C++:
void QsciTest::wheelEvent(QWheelEvent *event)
{
    if (event->modifiers().testFlag(Qt::ControlModifier)) {
        if (event->delta() > 0) {
            ui->textEdit->zoomIn();
        }
        else if(event->delta()<0){
            ui->textEdit->zoomOut();
        }
    }
}

EDIT2: So, zooming is working ok now, but auto-completion isnt working at all. I saw multiple examples of (supposedly) working code. I even looked at an old project of mine in python using pyqt, and the code was basically the same (and it worked).
C++:
    ui->setupUi(this);
    QsciScintilla *editor = ui->textEdit;
    editor->setMarginWidth(0, 32);
    editor->setTabWidth(4);

    QsciLexerJASS jass = new QsciLexerJASS(this);
    QsciAPIs api(&jass);
    api.add("aLongString23");
    api.add("aLongerString");
    api.add("aDifferentString");
    api.add("sOmethingElse");
    api.prepare();

    editor->setAutoCompletionThreshold(1);
    editor->setAutoCompletionSource(QsciScintilla::AcsAPIs);

    editor->setLexer(&jass);

It seems the lexer stops working as well.

If I declare the lexer like QsciLexerJASS *jass = new QsciLexerJASS(this); and use jass instead of &jass, the lexer works but the application crashes when it tries to show autocompletion window (I assume, because it crashes only when the auto-completion threshhold is reached). I can copy/paste all fine, too.

EDIT3: Nvm, I fixed it.
 
Last edited:
Status
Not open for further replies.
Top