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. How to invoke a widget window from a button?
Forum Updated to NodeBB v4.3 + New Features

How to invoke a widget window from a button?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 961 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.
  • J Offline
    J Offline
    JonathanAV95
    wrote on last edited by
    #1

    So i created a mainwindow.ui and a subwindow ui. The main ui will simply have buttons, and when the user triggers (Clicked) a button, it will open the subwindow. So by assumption, i realize that you simply show() the ui when user clicks.

    Or how would it really work? Just curious!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      You are right.
      You simple call show() method or if you need a modal dialog call exec() method in a slot function that is connected to onClick signal of a button.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JonathanAV95
        wrote on last edited by
        #3

        [quote author="andreyc" date="1418772423"]You are right.
        You simple call show() method or if you need a modal dialog call exec() method in a slot function that is connected to onClick signal of a button.[/quote]

        That seems simple, so create an object pointer for the new Widget header, then call show() inside the clicked() function?

        I got another question for you or anyone, so I have a simple line edit (TextEdit) were a user will insert they're 8 digit pin, I have a button that when click its purpose is to get the text inside the box and save it to a String (QString), I'm not a 100% how I can do it?

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hontonio
          wrote on last edited by
          #4

          You can connect the QPushButton::clicked() signal to your custom slot void getPin().

          declaration (.h)
          @class MyClass : QWidget {
          Q_OBJECT
          ...
          public slots:
          void getPin();
          }@

          implementation (.cpp)
          @
          QString MyClass::getPin() {
          target_qstring = ui->MyLineEdit->text;
          }
          @

          docs
          http://qt-project.org/doc/qt-4.8/signalsandslots.html

          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