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. Button
Qt 6.11 is out! See what's new in the release blog

Button

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 2.4k 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.
  • M Offline
    M Offline
    MKSPulok
    wrote on last edited by
    #1

    Hi, I'm new in Qt .I want to create a simple qt gui application .So i want to create a button and by clicking this button the user can get a message. How can I create this .. any help.??

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vidhya
      wrote on last edited by
      #2

      in the UI from just drag and drop the button and also lineedit or textarea what ever u need to display the message . then note the object name of the pushbutton and the lineedit
      then

      decalre the function in the header file void on_but_clicked()

      in the mainwindow.cpp add the Functio

      @
      void Mainwidget::on_but_clicked()
      {
      ui->line->settext("message");
      }
      @

      assume:
      objectnameof the button = but
      lineeditobject = line

      [EDIT: code formatting, please wrap in @-tags, Volker]

      Regards,
      Vidhya

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vidhya
        wrote on last edited by
        #3

        Void MainWindow name instead of MainWidget

        Regards,
        Vidhya

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rschaub
          wrote on last edited by
          #4

          Depends.
          If you've already got a main window with a button, you could use this:

          @
          CMainWindow::CMainWindow()
          {
          ...

          connect(m_ui->pButton, SIGNAL(pressed()), this, SLOT(SlotShowMessage()));
          }

          void CMainWindow::SlotShowMessage()
          {
          QMessageBox::warning(this, tr("title"), tr("text"));
          }
          @

          If you're starting from scratch, you could use one of the tutorial projects (there should be at least one that demonstrates how to create a mainwindow) and base your application on it, then use code similar to what I've posted above.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Vidhya
            wrote on last edited by
            #5

            or u can directly edit signal slot option in edit menu

            Regards,
            Vidhya

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MKSPulok
              wrote on last edited by
              #6

              thanks...

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mittu
                wrote on last edited by
                #7

                Hi, I’m new in Qt .I want to create a simple qt gui application .So i want to create a button and by clicking this button the user can get a message. How can I create this ..
                Again the same question with out using drag and drop option...
                Any help plz...

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

                  Hi and welcome to devnet,

                  Please don't revive old thread. Did you follow Qt's documentation tutorials and examples ? They provide all the informations you need to get started

                  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