Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt first project
Forum Updated to NodeBB v4.3 + New Features

Qt first project

Scheduled Pinned Locked Moved Qt Creator and other tools
59 Posts 7 Posters 24.9k Views 5 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.
  • N nick784512

    Hello,

    Here

    http://doc.qt.io/qtcreator/creator-writing-program.html

    it says:

    The on_findButton_clicked() slot is called automatically in the uic generated ui_textfinder.h file by this line of code:

    QMetaObject::connectSlotsByName(TextFinder);

    Where do I put this?

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by kshegunov
    #2

    Hi,

    @nick784512 said in Qt first project:

    connectSlotsByName

    Assuming you're using forms for your widgets, you don't. The moc will call that for you in Ui::FormClass::setupUi(QWidget *).

    Read and abide by the Qt Code of Conduct

    1 Reply Last reply
    2
    • N nick784512

      Hello,

      Here

      http://doc.qt.io/qtcreator/creator-writing-program.html

      it says:

      The on_findButton_clicked() slot is called automatically in the uic generated ui_textfinder.h file by this line of code:

      QMetaObject::connectSlotsByName(TextFinder);

      Where do I put this?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #3

      @nick784512

      Hi and welcome to devnet

      When you have followed the example it should work. This is only some explanation for your understanding, but apparently not really helpful.

      The file ui_*.h are automatically generated before the compilation. You can checkout this file for your understanding. You may even change it, but this is really not advisable, since it is frequently regenerated and therefore changed automatically.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      6
      • N Offline
        N Offline
        nick784512
        wrote on last edited by nick784512
        #4

        Thank you. Where can I find a website or a tutorial that has Qt examples?

        kshegunovK 1 Reply Last reply
        1
        • N nick784512

          Thank you. Where can I find a website or a tutorial that has Qt examples?

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #5

          On the Qt docs page: http://doc.qt.io/qt-5/qtexamplesandtutorials.html

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          5
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            HI
            Also in Creator, on the welcome page.
            There is "Examples"

            N 1 Reply Last reply
            3
            • mrjjM mrjj

              HI
              Also in Creator, on the welcome page.
              There is "Examples"

              N Offline
              N Offline
              nick784512
              wrote on last edited by
              #7

              Thank you,

              I am running the Blocking Master Example. Does anyone know how do I change the default COM1 to another COM, so that I can communicate with my arduino?

              mrjjM 1 Reply Last reply
              0
              • N nick784512

                Thank you,

                I am running the Blocking Master Example. Does anyone know how do I change the default COM1 to another COM, so that I can communicate with my arduino?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @nick784512 said in Qt first project:

                Blocking Master Example

                this line
                serial.setPortName(currentPortName);
                sets it.

                But that sample lets u select all detected com ports ?

                const auto infos = QSerialPortInfo::availablePorts();
                for (const QSerialPortInfo &info : infos)
                serialPortComboBox->addItem(info.portName());

                what comport should arduino be on?

                N 1 Reply Last reply
                1
                • mrjjM mrjj

                  @nick784512 said in Qt first project:

                  Blocking Master Example

                  this line
                  serial.setPortName(currentPortName);
                  sets it.

                  But that sample lets u select all detected com ports ?

                  const auto infos = QSerialPortInfo::availablePorts();
                  for (const QSerialPortInfo &info : infos)
                  serialPortComboBox->addItem(info.portName());

                  what comport should arduino be on?

                  N Offline
                  N Offline
                  nick784512
                  wrote on last edited by nick784512
                  #9

                  @mrjj said in Qt first project:

                  It does not let me select other port than COM1. Arduino should is connected on COM3.

                  mrjjM 1 Reply Last reply
                  0
                  • N nick784512

                    @mrjj said in Qt first project:

                    It does not let me select other port than COM1. Arduino should is connected on COM3.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @nick784512
                    Hi
                    You should try with other serial tool.
                    https://osdn.net/projects/ttssh2/releases/
                    and see if it can see it.
                    Or any other method to verify that the board is seen.

                    1 Reply Last reply
                    1
                    • N Offline
                      N Offline
                      nick784512
                      wrote on last edited by nick784512
                      #11

                      Finally it worked! I disconnected the mouse's usb receipter, I connected the arduino there, it didn't work and when I disconnected from there and connected to the original usb port, the Qt application displayed a COM3 port to choose and now it works!!!

                      1 Reply Last reply
                      1
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        Ok. super.
                        Sometimes is possible to use Device Manager and right click the comport and there change what comport it uses.

                        1 Reply Last reply
                        0
                        • N Offline
                          N Offline
                          nick784512
                          wrote on last edited by
                          #13

                          Hello, I want to build an application that will have a simple button and when I press it to send the command "START" through COM. I am looking the Blocking Master Example but I cannot find the .ui file in order to see how they have programmed the buttons. Any ideas???

                          mrjjM 1 Reply Last reply
                          0
                          • N nick784512

                            Hello, I want to build an application that will have a simple button and when I press it to send the command "START" through COM. I am looking the Blocking Master Example but I cannot find the .ui file in order to see how they have programmed the buttons. Any ideas???

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by mrjj
                            #14

                            @nick784512
                            Hi
                            Just Select File -> New Project -> Desktop Widget application
                            in this new project goto Form and click the mainwindow Ui file
                            Then drag a button from right left to the design area (main window)
                            Right click the button and select goto Slot
                            Select the "released()" signal from the list
                            You should now be in the code showing a slot for the button.
                            This code is called when button is clicked.

                            1 Reply Last reply
                            1
                            • N Offline
                              N Offline
                              nick784512
                              wrote on last edited by
                              #15

                              Hi, thank you. And which part of Blocking Master Example code do I choose to put inside the brackets of button released?

                              mrjjM 1 Reply Last reply
                              0
                              • N nick784512

                                Hi, thank you. And which part of Blocking Master Example code do I choose to put inside the brackets of button released?

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by mrjj
                                #16

                                @nick784512
                                The part you want to call when button is pushed.
                                In the sample, Dialog.cpp is the window. There is no UI file.

                                It calls
                                void Dialog::transaction()

                                But the real work in done is MasterThread.
                                So you cannot just put it into the button click.

                                If you are trying something simple,
                                this sample is maybe a bit complex to start with
                                using a thread with more.

                                To just open a comport and write "start", all you need it.
                                (Note. you should add more error checking code.)

                                so if you put in slot

                                QSerialPort serial;
                                serial.setPortName("com1");
                                serial.open(QIODevice::ReadWrite);
                                serial.setBaudRate(QSerialPort::Baud115200); // MAKE SURE ITS CORRECT
                                serial.setDataBits(QSerialPort::Data8); // MAKE SURE ITS CORRECT
                                serial.setParity(QSerialPort::NoParity); // MAKE SURE ITS CORRECT
                                serial.setStopBits(QSerialPort::OneStop); // MAKE SURE ITS CORRECT
                                serial.setFlowControl(QSerialPort::HardwareControl); // MAKE SURE ITS CORRECT
                                
                                if (serial.isOpen() && serial.isWritable())
                                {
                                 qDebug() << "Serial is open";
                                  output = "START";
                                  serial.write(output);
                                  serial.waitForBytesWritten(1000);
                                qDebug() << "sent";
                                }
                                

                                if you need a design where "the other end" answers, QSerialPort serial should live as member
                                of mainwindow.

                                Btw:
                                this sample
                                http://doc.qt.io/qt-5/qtserialport-terminal-example.html
                                Can send text and show what comes back. its super for testing.

                                1 Reply Last reply
                                1
                                • N Offline
                                  N Offline
                                  nick784512
                                  wrote on last edited by nick784512
                                  #17

                                  Thank you. What version of C++ does the Qt use? It is the "classic" C++ or C++11?

                                  mrjjM 1 Reply Last reply
                                  0
                                  • N nick784512

                                    Thank you. What version of C++ does the Qt use? It is the "classic" C++ or C++11?

                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by mrjj
                                    #18

                                    @nick784512
                                    Both. I think from 5.7 it must be c++11 but 5.6 LTS can be build with pre c++11.
                                    https://blog.qt.io/blog/2015/12/18/introducing-long-term-support/

                                    1 Reply Last reply
                                    2
                                    • N Offline
                                      N Offline
                                      nick784512
                                      wrote on last edited by
                                      #19

                                      Hello, Can someone send me a Qt program with one button that when I press it, it sends the command "START" through COM ? I am trying to figure out from Qt examples, but the more I read the more I am confused.

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

                                        Hi,

                                        What exactly is confusing you ?

                                        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
                                        • N Offline
                                          N Offline
                                          nick784512
                                          wrote on last edited by nick784512
                                          #21

                                          The "terminal" example has so many functions, but too little explanation. How am I supposed to learn how it works, and what functions to use in my simple program (see above)?

                                          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