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. [SOLVED] Buttons doesn't "activate"
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Buttons doesn't "activate"

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 4.2k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    stereoid
    wrote on last edited by
    #1

    Hi,

    I'm a beginning programmer and new to Qt , so the question might be stupid, but i follow the youtube tutorials from user "rootshell" and when i deploy any widget at mainwindow.ui it is enabled but it isn't "activated" in a sense that i can't click it (e.g. can't check the checkbox or radio button). The only way i can do that is when i use grabMouse (or e.g. grabKeyboard) function but when i try to use the same function on various buttons (e.g. grabMouse on radioButton and on radioButton_2) only the last one works (the others can't be checked). What's the problem here?
    I should add that in the properties window field "enabled" is checked, and when i additionally use setEnabled(true) function on buttons nothing changes... any help?
    P.S. I use Qt Creator 2.7.0

    Regards

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What OS are you on ? What version of Qt ?

      Do you have a minimal example of your code that doesn't do what you want ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stereoid
        wrote on last edited by
        #3

        Hi,
        i work on windows 7, Qt Creator 2.7.0 based on Qt 5.0.2 (32bit).
        mainwindow.cpp
        @#include "mainwindow.h"
        #include "ui_mainwindow.h"

        MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);
        ui->pushButton->grabMouse();
        ui->pushButton->setText("close");
        connect(ui->horizontalSlider,SIGNAL(valueChanged(int)),
        ui->progressBar,SLOT(setValue(int)));
        ui->horizontalSlider->grabKeyboard();
        ui->radioButton->setEnabled(true);
        ui->radioButton_2->setEnabled(true);
        }

        MainWindow::~MainWindow()
        {
        delete ui;
        }
        @
        in this case Push button does work (because i used grabMouse function) and slider reacts only for keyboard arrows, doesn't react for mouse. radio buttons doesn't do anything (doesn't "check" themselves). Also when i add grabMouse on radioButtons only the last assigned button works (e.g radioButton_2 does work, and push button and radioButton don't)
        Here's my window:
        http://imageshack.us/photo/my-images/443/34893757.png/?sa=0

        PS i set textname for radioButtons and starting point for progress bar (from 24% to 0%) from property window

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Removing the two grab functions:

          What do you expect from your close button ?
          Do you expect your slider to move using your keyboard before giving it focus with the mouse ? Which key are you using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stereoid
            wrote on last edited by
            #5

            well, when i removed the first one (pushButton->grabMouse) everything works ok,
            big thanks for help and sorry for taking your time :)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              grabMouse and grabKeyboard should only be used in specific conditions. Most of the time you won't need them at all.

              You're welcome !

              Don't forget to update the thread's title to solved so other forum users may know that a solution has been found :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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