Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Disable OK button in ButtonBox (in mobile development)
Forum Updated to NodeBB v4.3 + New Features

Disable OK button in ButtonBox (in mobile development)

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 3 Posters 13.0k 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.
  • T Offline
    T Offline
    Tsukasa
    wrote on 5 Apr 2011, 13:47 last edited by
    #1

    I have a typical dialog window that is invoked from main window using a button via exec() call.
    This window contain "buttonBox" that translates to standard "soft buttons" Ok and Cancel.
    I want application to disable "OK" button till correct value is received from user in dialog.

    In dialog constructor I have:

    @
    ui->setupUi(this);
    ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
    @

    but it does not affect the actual behaviour, the button is available and dialog is closed when it's pressed.

    How I can disable/reenable a standard button in mobile app dialog?

    [EDIT: code formatting, please use @-Tags, Volker]

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 5 Apr 2011, 14:45 last edited by
      #2

      This must be done in the show event. The buttons are enabled after the constructor :-( I had some similar problems and solved it by a flag (Initialised) and done it once in the show event.

      @
      myDialog::showEvent()
      {
      if(!initialized)
      {
      initialized = true;
      ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
      }
      }
      @

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on 5 Apr 2011, 15:08 last edited by
        #3

        Indeed, I stumbled on this as well. An alternative approach is to use a single-shot timer that you trigger from the constructor.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tsukasa
          wrote on 6 Apr 2011, 16:08 last edited by
          #4

          Hi, thanks for the advice! Did it also work for you in emulator? Because I incorporated this method now but without an apparent effect.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on 6 Apr 2011, 17:26 last edited by
            #5

            I am working on desktop, not on the mobile. So sorry, I can't tell you if this works in the emulator.

            1 Reply Last reply
            0

            1/5

            5 Apr 2011, 13:47

            • Login

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