Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt-> how to set ALT key active

Qt-> how to set ALT key active

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    iuliancalin
    wrote on 29 Jul 2014, 17:44 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on 29 Jul 2014, 18:39 last edited by
      #2

      What do you mean "active Alt key" ?

      1 Reply Last reply
      0
      • I Offline
        I Offline
        iuliancalin
        wrote on 29 Jul 2014, 19:35 last edited by
        #3

        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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on 29 Jul 2014, 19:49 last edited by
          #4

          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

          1 Reply Last reply
          0

          1/4

          29 Jul 2014, 17:44

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved