Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. Slot
Qt 6.11 is out! See what's new in the release blog

Slot

Scheduled Pinned Locked Moved India
28 Posts 7 Posters 22.1k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi Everybody...Warm greetings to All.I need a help from you guys.Am very new to coding and presently my work is with Qt.So I started with it and I have a problem in connecting the slot.

    My idea is to connect a lineEdit to the LCD,whenever I type a number in the lineEdit,the LCD should display the same.
    Am using QtCreator for doing this.

    Please help me to proceed further.

    Thank you All in advance.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      baysmith
      wrote on last edited by
      #2

      Post a small code example of what you are trying to do, so that we may help you with the details.

      Nokia Certified Qt Specialist.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        I got it done with the QtCreator.
        I used the following code to validate my lineEdit to accept only numbers.

        QRegExp rx( "^[0-9]*$" );
        QValidator *validator = new QRegExpValidator(rx, this);
        lineEdit->setValidator( validator );

        Thank You

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          How to check the overflow of LCD in Qt?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Check this signal:

            http://doc.qt.nokia.com/4.7/qlcdnumber.html#overflow

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              [quote author="Revu" date="1298007867"]I got it done with the QtCreator.
              I used the following code to validate my lineEdit to accept only numbers.

              QRegExp rx( "^[0-9]*$" );
              QValidator *validator = new QRegExpValidator(rx, this);
              lineEdit->setValidator( validator );

              Thank You[/quote]

              You could also use "QSpinBox":http://doc.qt.nokia.com/4.7/qspinbox.html instead of a line editor or use a ready built "QIntValidator":http://doc.qt.nokia.com/4.7/qintvalidator.html on your line edit.

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Go through this link...This may be helpful to you..

                http://doc.qt.nokia.com/4.7/tutorials-addressbook.html

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  @All thank you

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    Now I have a new problem.

                    I have two forms in QtCreator.How do I link both?
                    A click of a button on the main window should display the other window.
                    Can I do this by saving both the forms into the same folder and then create a slot in the mainwindow?

                    Please help me...
                    Reply at the earliest will help me a lot.

                    Thanks in advance

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #10

                      First: for new questions, a new thread would be fine, so the topics are separated.

                      Regarding your problem: You have a class that implements your form. In this class you have the slots for the buttons. There you can show the other form, same as showing dialogs etc.

                      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
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #11

                        @Geroif:ok sorry for that...

                        I thought this is concerned with slot so i could post here..

                        Well still am not clear about the solution.It would be better if it is in steps.

                        Thank you

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          giesbert
                          wrote on last edited by
                          #12

                          The normal way of using designer created forms is:

                          create them in designer

                          in your project, create a class that uses the QtDesigner created ui stuff to build it's UI and implement the logic in the class

                          in this class you implement the slots, so you can also implement a slot for a button (see the docs, bock, examples...)

                          in that slot you can show your second form. (MyDesignerClass2.show() ) where MyDesignerClass2 is the class you use for implementing the UI for the second form. It can't be done directly in QtDesigner.

                          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
                          • ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #13

                            @Geroif:I will try out with it .
                            Thank You

                            1 Reply Last reply
                            0
                            • ? Offline
                              ? Offline
                              A Former User
                              wrote on last edited by
                              #14

                              @Geroif:I think almost is done.But how to declare the second designer form in the scope of first form in its .cpp file.

                              1 Reply Last reply
                              0
                              • ? Offline
                                ? Offline
                                A Former User
                                wrote on last edited by
                                #15

                                [quote author="Revu" date="1298372699"]@Geroif:I think almost is done.But how to declare the second designer form in the scope of first form in its .cpp file.[/quote]

                                The usual way is to have one cpp class per form file (.ui). To use one of the forms in another cpp file, include the headers as you do for ordinary classes too.

                                1 Reply Last reply
                                0
                                • ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on last edited by
                                  #16

                                  @Volker:Thanks for that tip.

                                  Should I have a file(.h) for my second form too?

                                  1 Reply Last reply
                                  0
                                  • ? Offline
                                    ? Offline
                                    A Former User
                                    wrote on last edited by
                                    #17

                                    Yes.

                                    1 Reply Last reply
                                    0
                                    • G Offline
                                      G Offline
                                      giesbert
                                      wrote on last edited by
                                      #18

                                      Of course!

                                      Each form should be a class, and a class should have header and cpp (if its not pure inline or template).
                                      The designer is only some helper tool to not do all the coding for ui representation by hand (what I personally prefer).

                                      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
                                      • ? Offline
                                        ? Offline
                                        A Former User
                                        wrote on last edited by
                                        #19

                                        am not able to get it done...how could I attach my code with the message to get help ?

                                        1 Reply Last reply
                                        0
                                        • ? Offline
                                          ? Offline
                                          A Former User
                                          wrote on last edited by
                                          #20

                                          Am getting error after compiling.The code is as follows:
                                          @#include <QtGui>

                                          #include "mainwindow.h"
                                          #include "subWindow.h"

                                          int main(int argc , char *argv[])
                                          {
                                          QApplication app(argc,argv);

                                              mainwindow mWindow;
                                              mWindow.show();
                                              subWindow window;
                                              window.show();
                                          
                                              QObject::connect( &mWindow, SIGNAL(Clicked()),
                                              &window, SLOT(on_next_clicked()));
                                          
                                              return app.exec();
                                          

                                          }
                                          @

                                          the error is:

                                          main.cpp: In function ‘int main(int, char**)’:
                                          main.cpp:10: error: ‘mainwindow’ was not declared in this scope
                                          main.cpp:10: error: expected ‘;’ before ‘mWindow’
                                          main.cpp:11: error: ‘mWindow’ was not declared in this scope
                                          make: *** [main.o] Error 1

                                          please help

                                          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