Qt-> how to set ALT key active



  • Can someone please explain how to set the Alt key as active permanently?
    I'm trying to make an application for Ubuntu and I need to make it active.
    I want to add it to the code below in the if statement:

    @ void MainWindow::on_checkBoxTitleBar_toggled(bool checked)
    {
    settings->setValue("systemTitle", checked);
    ui->buttonMinimize->setVisible(!checked);
    ui->buttonClose->setVisible(!checked);

        if(!checked) {
            this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint );
            //here i whant the new code line for the ALT key
        } else {
            this->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint );
    }@
    

    I'm new to C++, just don't really understand how C++ works, but I'm trying.



  • What do you mean "active Alt key" ?



  • i mean the ALT key on my keaboard to be active even if its not pressed
    i want this for using it with the mouse buttons left right buttons

    i just want to try someting to see if it works

    for example i have in my app a QWidget with the class centralWidget if i click it it sould know that the ALT key is pressed but in reality it is not

    in my mind is looks like this:
    this->setActive(Qt::Key_Alt);
    but this is not c++ valid so can please someone show me an example



  • In Qt app the developer decides how to interpret the input including the pressed keys and mouse buttons.
    For each widget the app receives "the events":http://qt-project.org/doc/qt-5/qwidget.html#events for example "QWidget::keyPressEvent()":http://qt-project.org/doc/qt-5/qwidget.html#keyPressEvent or "QWidget::mousePressEvent()":http://qt-project.org/doc/qt-5/qwidget.html#mousePressEvent the QEvent parameter will contain an info about the event.

    If you need to make Alt key active then

    Create a flag that will tell you that user want an active-Alt.

    Implement mousePressEvent for all widgets that need to use the active-Alt flag


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.