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. Qt Programming Language

Qt Programming Language

Scheduled Pinned Locked Moved Unsolved General and Desktop
331 Posts 17 Posters 306.3k Views
  • 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.
  • SGaistS SGaist

    You can use a QLabel when you want to show some text.

    What I meant is something like:

    class SpouseWidget : public QWidget {
        Q_OBJECT
    public:
        enum Gender {
            Bride,
            Groom
        }
    public:
        SpouseWidget(QWidget *parent = 0);
        QString name() const;
        Gender gender() const;
    
    private:
         QLineEdit *nameLineEdit;
        QButtonGroup *genderButtonGroup;
    };
    
    SpouseWidget::SpouseWidget(QWidget *parent):
        QWidget(parent),
        nameLineEdit(new QLineEdit),
        genderButtonGroup(new QButtonGroup(this)
    
        QRadioButton *brideButton = new QRadioButton (tr("Bride"));
        brideButton->setProperty("gender", SpouseWidget::Bride);
        bride->setChecked(true);
        QRadioButton *groomButton = new QRadioButton (tr("Groom"));
        groomButton->setProperty("gender", SpouseWidget::Groom);
    
        genderButtonGroup->add(brideButton);
        genderButtonGroup->add(groomButton);
        QHBoxLayout *genderLayout = new QHBoxLayout;
        genderLayout->addWidget(brideButton);
        genderLayout->addWidget(groomButton);
    
        QFormLayout *layout = new QFormLayout(this);
        layout->addRow(tr("Name"), nameLineEdit);
        layout->addRow(tr("Gender"), genderLayout);
    }
    
    QString SpouseWidget::name() const 
    {
        return nameLineEdit->text();
    }
    
    SpouseWidget::Gender SpouseWidget::gender() const
    {
        QAbstractButton *button = genderButtonGroup->checkedButton();
        QVariant genderVariant = button->property("gender");
        return genderVariant.value<SpouseWidget::Gender>()
    }
    

    Then in your page you can use a QGroupBox for each spouse with an instance of SpouseWidget inside.

    A Offline
    A Offline
    Annabelle
    wrote on last edited by
    #34

    @SGaist said in Qt Programming Language:

    You can use a QLabel when you want to show some text.

    What I meant is something like:

    class SpouseWidget : public QWidget {
        Q_OBJECT
    public:
        enum Gender {
            Bride,
            Groom
        }
    public:
        SpouseWidget(QWidget *parent = 0);
        QString name() const;
        Gender gender() const;
    
    private:
         QLineEdit *nameLineEdit;
        QButtonGroup *genderButtonGroup;
    };
    
    SpouseWidget::SpouseWidget(QWidget *parent):
        QWidget(parent),
        nameLineEdit(new QLineEdit),
        genderButtonGroup(new QButtonGroup(this)
    
        QRadioButton *brideButton = new QRadioButton (tr("Bride"));
        brideButton->setProperty("gender", SpouseWidget::Bride);
        bride->setChecked(true);
        QRadioButton *groomButton = new QRadioButton (tr("Groom"));
        groomButton->setProperty("gender", SpouseWidget::Groom);
    
        genderButtonGroup->add(brideButton);
        genderButtonGroup->add(groomButton);
        QHBoxLayout *genderLayout = new QHBoxLayout;
        genderLayout->addWidget(brideButton);
        genderLayout->addWidget(groomButton);
    
        QFormLayout *layout = new QFormLayout(this);
        layout->addRow(tr("Name"), nameLineEdit);
        layout->addRow(tr("Gender"), genderLayout);
    }
    
    QString SpouseWidget::name() const 
    {
        return nameLineEdit->text();
    }
    
    SpouseWidget::Gender SpouseWidget::gender() const
    {
        QAbstractButton *button = genderButtonGroup->checkedButton();
        QVariant genderVariant = button->property("gender");
        return genderVariant.value<SpouseWidget::Gender>()
    }
    

    Then in your page you can use a QGroupBox for each spouse with an instance of SpouseWidget inside.

    After I compile all my widgets in Notepad++, how would I turn them into an executable program?

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

      You can use a QLabel to show the text and add it at the bottom of the QFormLayout without specifying a text.

      As for your question with Notepad++, maybe using this plugin ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 2 Replies Last reply
      0
      • SGaistS SGaist

        You can use a QLabel to show the text and add it at the bottom of the QFormLayout without specifying a text.

        As for your question with Notepad++, maybe using this plugin ?

        A Offline
        A Offline
        Annabelle
        wrote on last edited by
        #36

        @SGaist said in Qt Programming Language:

        You can use a QLabel to show the text and add it at the bottom of the QFormLayout without specifying a text.

        As for your question with Notepad++, maybe using this plugin ?

        Could you please explain what you mean when you say, "You can use a QLabel to show the text and add it at the bottom of the QFormLayout without specifying a text."? I'm a bit confused on that one!

        1 Reply Last reply
        0
        • SGaistS SGaist

          You can use a QLabel to show the text and add it at the bottom of the QFormLayout without specifying a text.

          As for your question with Notepad++, maybe using this plugin ?

          A Offline
          A Offline
          Annabelle
          wrote on last edited by
          #37

          @SGaist said in Qt Programming Language:

          You can use a QLabel to show the text and add it at the bottom of the QFormLayout without specifying a text.

          As for your question with Notepad++, maybe using this plugin ?

          I tried installing that plugin, but when I launched Notepad++, a screen popped up with a message telling me that the plugin isn't compatible with the version of Notepad++ I have. Is that because I have a newer version of Notepad++? I'm confused on that one!

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

            Like shown in my sample widget, you should use layouts in order to place your widgets around in your application. Therefore my suggestion, put your text into a QLabel with setText and then put that label at the appropriate place within the layout.

            As for the plugin, it might be out of date regarding the version of Notepad++. If possible, I'd recommend using Qt Creator in order to build your application. It would likely make things easier.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            A 1 Reply Last reply
            0
            • A Offline
              A Offline
              Annabelle
              wrote on last edited by
              #39

              How would I be able to use QT Creator to make my project? Would I put the code I've already made in Notepad++ into a new project in Qt Creator? What would I do?

              1 Reply Last reply
              0
              • SGaistS SGaist

                Like shown in my sample widget, you should use layouts in order to place your widgets around in your application. Therefore my suggestion, put your text into a QLabel with setText and then put that label at the appropriate place within the layout.

                As for the plugin, it might be out of date regarding the version of Notepad++. If possible, I'd recommend using Qt Creator in order to build your application. It would likely make things easier.

                A Offline
                A Offline
                Annabelle
                wrote on last edited by
                #40

                @SGaist said in Qt Programming Language:

                Like shown in my sample widget, you should use layouts in order to place your widgets around in your application. Therefore my suggestion, put your text into a QLabel with setText and then put that label at the appropriate place within the layout.

                As for the plugin, it might be out of date regarding the version of Notepad++. If possible, I'd recommend using Qt Creator in order to build your application. It would likely make things easier.

                I can't access Qt Creator with my screenreader, JAWS (Job Access With Speech). That's why I'm making the code in Notepad++. I just wish I knew how to make the finished program.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Annabelle
                  wrote on last edited by
                  #41

                  I'm still a bit stuck on this Qt Programming Language. Since I can't access Qt Creator with my JAWS screenreader, as it doesn't recognize image-based icons, how else can I create a finished program after compiling the source code in Notepad++? Anybody have any answers for me?

                  mrjjM 1 Reply Last reply
                  0
                  • A Annabelle

                    I'm still a bit stuck on this Qt Programming Language. Since I can't access Qt Creator with my JAWS screenreader, as it doesn't recognize image-based icons, how else can I create a finished program after compiling the source code in Notepad++? Anybody have any answers for me?

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

                    @Annabelle
                    So you can compile it already?
                    Or is it the compiling part that is hard to do ?

                    Can the JAWS read a command prompt ?

                    A 1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Annabelle
                      wrote on last edited by
                      #43

                      I'm still a bit confused on how to make the finished program. I can't access the Qt Creator, since my screenreader, or any screenreaders, for that matter, won't recognize image-based icons. Is there a way for someone blind like me to create a finished program such as the app I'm putting together, after compiling the source code in Notepad++?

                      1 Reply Last reply
                      0
                      • sierdzioS Offline
                        sierdzioS Offline
                        sierdzio
                        Moderators
                        wrote on last edited by
                        #44

                        Do you have the code ready, with a .pro file (it is a project definition file that Qt uses to compile applications)? If yes, then you can compile your project from the command line. Open cmd.exe (I guess you are on Windows operating system) and type:

                        qmake yourprojectname.pro
                        make
                        

                        That should be enough, assuming your environment is prepared (qmake and compiler are both set up in PATH system variable).

                        As a side note, as far as I know there is an accessibility team working at Qt Company, I'm sure they will be happy to hear how both Qt and Qt Creator can be improved to help blind people. You can try reaching them at qt-creator@qt-project.org. You can also subscribe to Qt Creator mailing list here: http://lists.qt-project.org/mailman/listinfo/qt-creator.

                        (Z(:^

                        A 1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @Annabelle
                          So you can compile it already?
                          Or is it the compiling part that is hard to do ?

                          Can the JAWS read a command prompt ?

                          A Offline
                          A Offline
                          Annabelle
                          wrote on last edited by
                          #45

                          @mrjj said in Qt Programming Language:

                          @Annabelle
                          So you can compile it already?
                          Or is it the compiling part that is hard to do ?

                          Can the JAWS read a command prompt ?

                          I can make the source code, it's the compiling the finished program part that's hard. Yes, JAWS can read a Command Prompt. What do I do in there?

                          AllanisA 1 Reply Last reply
                          0
                          • AllanisA Offline
                            AllanisA Offline
                            Allanis
                            wrote on last edited by
                            #46

                            Hi, you will need to create a .pro file which gives instructions on how to build your application. http://doc.qt.io/qt-4.8/qmake-project-files.html

                            Once you have have this. you can do as instructed by @sierdzio in CMD.

                            1 Reply Last reply
                            0
                            • A Annabelle

                              @mrjj said in Qt Programming Language:

                              @Annabelle
                              So you can compile it already?
                              Or is it the compiling part that is hard to do ?

                              Can the JAWS read a command prompt ?

                              I can make the source code, it's the compiling the finished program part that's hard. Yes, JAWS can read a Command Prompt. What do I do in there?

                              AllanisA Offline
                              AllanisA Offline
                              Allanis
                              wrote on last edited by Allanis
                              #47

                              @Annabelle Sorry, I was at work when I made my initial response to this thread. A more elaborate answer for you follows as I take it you are beginning in Qt and it may be difficult for you to look up resources.

                              Given the scope of your project I think it will suffice to use a simple Qmake project file such as:

                              myapp.pro

                              TEMPLATE = app
                              
                              QT += widgets
                              
                              SOURCES += main.cpp \
                                  MainWindow.cpp \
                                  SpouseWidget.cpp
                              
                              HEADERS += \
                                  MainWindow.h \
                                  SpouswWidget.h
                              
                              OTHER_FILES += \
                                  anyotherfile.png
                              

                              You may need to make changes to this in order to fit the needs of your project, but this should be a good enough example for you.

                              Once you have this in place, you can open up your favorite Command Line Interface (eg. cmd.exe for Windows).

                              Type:

                              qmake myapp.pro
                              make
                              

                              Your compiler will generate a binary file for your application at this point.

                              I hope this helps,
                              Have fun.

                              AllanisA A 2 Replies Last reply
                              0
                              • A Offline
                                A Offline
                                Annabelle
                                wrote on last edited by
                                #48

                                Another thing I'd like to do is make icons for the push buttons, radio buttons, combo boxes, and checkboxes. I'd like to find out, is it OK for me to use unicode symbols as icons? For example:
                                In the welcome screen, there are the following Radio Buttons
                                ⚭ (Wedding Ceremony Radio Button)
                                ~β›² (Baptism Ceremony Radio Button)
                                β›Ό (Funeral Ceremony Radio Button)
                                For the Spouse Genders, there should be the following Icons:
                                πŸ‘° (Bride Radio Button)
                                🀡 (Groom Radio Button)
                                For the Baptism Person Types, there should be the following Icons:
                                πŸ‘¦πŸ‘ΆπŸ‘§ (Infant Radio Button)
                                πŸ‘¦πŸ‘§ (Child Radio Button)
                                πŸ‘¦πŸ‘¨πŸ‘§πŸ‘© (Youth Radio Button)
                                πŸ‘¨πŸ‘΄πŸ‘©πŸ‘΅ (Adult Radio Button)
                                For the Funeral Ceremony Types, there should be the following icons:
                                ⚰ (Funeral Radio Button)
                                ⚱ (Memorial Service Radio Button)
                                Note that some of the icons are composed of two or more unicode characters put together, as I couldn't find separate unicode symbols to represent them.

                                1 Reply Last reply
                                0
                                • AllanisA Offline
                                  AllanisA Offline
                                  Allanis
                                  wrote on last edited by
                                  #49

                                  You should be able to use QString::fromUtf8() for this: http://doc.qt.io/qt-5/qstring.html#fromUtf8

                                  A 1 Reply Last reply
                                  1
                                  • AllanisA Allanis

                                    You should be able to use QString::fromUtf8() for this: http://doc.qt.io/qt-5/qstring.html#fromUtf8

                                    A Offline
                                    A Offline
                                    Annabelle
                                    wrote on last edited by
                                    #50

                                    @Allanis said in Qt Programming Language:

                                    You should be able to use QString::fromUtf8() for this: http://doc.qt.io/qt-5/qstring.html#fromUtf8

                                    Could you please be so kind as to give me an example of what one of my icons would look like with the QString::fromUtf8() code? For example: πŸ‘¦πŸ‘ΆπŸ‘§

                                    1 Reply Last reply
                                    0
                                    • AllanisA Offline
                                      AllanisA Offline
                                      Allanis
                                      wrote on last edited by Allanis
                                      #51

                                      Sure. I'm not sure exactly what you mean. Do you want an image or a code example? either way I whipped up a quick example to demonstrate what it would look like. Here's an image.

                                      0_1506120620297_annabelle.png

                                      Given that your first post mentioned you where visually impaired, I think I may have misunderstood your meaning, so here's an example in code:

                                        QRadioButton* rb = new QRadioButton();
                                        QString str = QString::fromUtf8("<Utf-8 code> Button Name");
                                        rb->setText(str);
                                      

                                      Where <Utf-8 code> = the character you wish to display.
                                      Pretty sure there is a nicer way to do it. But I'm off to bed. That should get you started though.

                                      A 1 Reply Last reply
                                      0
                                      • AllanisA Allanis

                                        Sure. I'm not sure exactly what you mean. Do you want an image or a code example? either way I whipped up a quick example to demonstrate what it would look like. Here's an image.

                                        0_1506120620297_annabelle.png

                                        Given that your first post mentioned you where visually impaired, I think I may have misunderstood your meaning, so here's an example in code:

                                          QRadioButton* rb = new QRadioButton();
                                          QString str = QString::fromUtf8("<Utf-8 code> Button Name");
                                          rb->setText(str);
                                        

                                        Where <Utf-8 code> = the character you wish to display.
                                        Pretty sure there is a nicer way to do it. But I'm off to bed. That should get you started though.

                                        A Offline
                                        A Offline
                                        Annabelle
                                        wrote on last edited by
                                        #52

                                        @Allanis said in Qt Programming Language:

                                        Sure. I'm not sure exactly what you mean. Do you want an image or a code example? either way I whipped up a quick example to demonstrate what it would look like. Here's an image.

                                        0_1506120620297_annabelle.png

                                        Given that your first post mentioned you where visually impaired, I think I may have misunderstood your meaning, so here's an example in code:

                                          QRadioButton* rb = new QRadioButton();
                                          QString str = QString::fromUtf8("<Utf-8 code> Button Name");
                                          rb->setText(str);
                                        

                                        Where <Utf-8 code> = the character you wish to display.
                                        Pretty sure there is a nicer way to do it. But I'm off to bed. That should get you started though.

                                        So are you thinking I should write something like:
                                        QRadioButton* rb = new QRadioButton();
                                        QString str = QString::fromUtf8("<πŸ‘°> Button Name");
                                        rb->setText(str);
                                        And for "Button Name", would it be something like:
                                        QRadioButton* rb = new QRadioButton();
                                        QString str = QString::fromUtf8("<πŸ‘°> Bride");
                                        rb->setText(str);
                                        Something along those lines?

                                        1 Reply Last reply
                                        0
                                        • AllanisA Offline
                                          AllanisA Offline
                                          Allanis
                                          wrote on last edited by
                                          #53

                                          Yeah that will work. But remove the <> from around your unicode character. I only placed them their as placeholder. It will work by placing the unicode character in your source file as you have done, but I would recommend finding the value for it instead. I'm replying from my phone so I can't look ot up for you.

                                          A 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