Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Advice about the application I will be making? (I'm a beginner)
Forum Updated to NodeBB v4.3 + New Features

Advice about the application I will be making? (I'm a beginner)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
77 Posts 6 Posters 25.4k Views 2 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.
  • D dvlpr.bernard

    Okay, did you mean this string? I already tried it but it didn't work I think it is one liner meaning I can't put two or more line data.

    0_1556192247323_cb9def4a-6675-4b99-9615-d7151c9d178c-image.png

    I want store an image to make it look more a real code rather than just a plain text, but if it is not possible thats fine.
    0_1556192503849_c8f12403-d6c9-48af-bb84-37ba1b9cdfa5-image.png

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

    @dvlpr.bernard
    where you have string, if u open drop down, there is not TEXT type ?

    ahh. that way.
    well we can fix that later with a syntax highlighter
    https://doc.qt.io/qt-5/qtwidgets-richtext-syntaxhighlighter-example.html
    so when we set text texts its formatted with colors. no need to store image of it.

    D 1 Reply Last reply
    2
    • mrjjM mrjj

      @dvlpr.bernard
      where you have string, if u open drop down, there is not TEXT type ?

      ahh. that way.
      well we can fix that later with a syntax highlighter
      https://doc.qt.io/qt-5/qtwidgets-richtext-syntaxhighlighter-example.html
      so when we set text texts its formatted with colors. no need to store image of it.

      D Offline
      D Offline
      dvlpr.bernard
      wrote on last edited by
      #28

      @mrjj
      Uhhmm I see, I need to use Text rather than string.
      Thank you, thank you!

      mrjjM 1 Reply Last reply
      0
      • D dvlpr.bernard

        @mrjj
        Uhhmm I see, I need to use Text rather than string.
        Thank you, thank you!

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

        @dvlpr.bernard
        string is a way to optimize the db so one can set a fixed size so if all text is within that, its more efficient, however, for your case with 75 questions. just use TEXT type.

        D 1 Reply Last reply
        1
        • mrjjM mrjj

          @dvlpr.bernard
          string is a way to optimize the db so one can set a fixed size so if all text is within that, its more efficient, however, for your case with 75 questions. just use TEXT type.

          D Offline
          D Offline
          dvlpr.bernard
          wrote on last edited by
          #30

          @mrjj
          Sir. Just wondering how can I access the string value from other functions? I want to use it in other functions.

          0_1556204335320_ff86f8e5-34df-453a-887c-a9a1f3df8d9f-image.png

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

            Hi
            what string do you mean ?
            The Topic column string from the data base ?

            D 1 Reply Last reply
            2
            • mrjjM mrjj

              Hi
              what string do you mean ?
              The Topic column string from the data base ?

              D Offline
              D Offline
              dvlpr.bernard
              wrote on last edited by
              #32

              @mrjj Hello, no. I mean the QString ch_topic whenever the user chooses a topic. How I'm going to get the ch_topic in order to use it in other functions?

              mrjjM 1 Reply Last reply
              0
              • D dvlpr.bernard

                @mrjj Hello, no. I mean the QString ch_topic whenever the user chooses a topic. How I'm going to get the ch_topic in order to use it in other functions?

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

                @dvlpr.bernard
                Hi
                Just store in main window class.
                All the data you want to be shared between functions should be part of MainWindow. (in .h)
                At least stuff like selected Topic etc.

                D 1 Reply Last reply
                1
                • mrjjM mrjj

                  @dvlpr.bernard
                  Hi
                  Just store in main window class.
                  All the data you want to be shared between functions should be part of MainWindow. (in .h)
                  At least stuff like selected Topic etc.

                  D Offline
                  D Offline
                  dvlpr.bernard
                  wrote on last edited by
                  #34

                  @mrjj
                  Hello, Hmm didn't know why this is happening. What I did wrong?

                  0_1556212301978_004fed1f-b35c-473b-ac23-46e096ec3041-image.png
                  0_1556212325470_a4634d6a-f4a2-4b72-a254-2cd4b79ab393-image.png

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

                    Hi
                    You say get_ch_topic is of type MainWindow ???
                    Should it not QString ?
                    Or do you mean it should be a function to return
                    the ch_topic ?
                    In any case, type of MainWindow just seems wrong.

                    D 1 Reply Last reply
                    1
                    • mrjjM mrjj

                      Hi
                      You say get_ch_topic is of type MainWindow ???
                      Should it not QString ?
                      Or do you mean it should be a function to return
                      the ch_topic ?
                      In any case, type of MainWindow just seems wrong.

                      D Offline
                      D Offline
                      dvlpr.bernard
                      wrote on last edited by
                      #36

                      @mrjj
                      I don't know. But I want to define a global object so that other functions can use it. But I just don't know where to declare it

                      mrjjM 1 Reply Last reply
                      0
                      • D dvlpr.bernard

                        @mrjj
                        I don't know. But I want to define a global object so that other functions can use it. But I just don't know where to declare it

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

                        @dvlpr.bernard
                        Hi
                        Just like the
                        QString ch_topic;
                        Then all member functions have access to it as they are part of the class.

                        D 1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @dvlpr.bernard
                          Hi
                          Just like the
                          QString ch_topic;
                          Then all member functions have access to it as they are part of the class.

                          D Offline
                          D Offline
                          dvlpr.bernard
                          wrote on last edited by
                          #38

                          @mrjj
                          whenever I use qDebug() <<get_ch_Topic.getTopic() in the same function where ch_topic was define it returns "IF". But when I use qDebug() <<get_ch_Topic.getTopic() in other functions it return "". I don't know why but maybe because the object name was different?

                          0_1556213404603_c1fd677f-9d65-4757-823b-cd0ca12c8cd1-image.png

                          0_1556213335075_393dae0b-1e06-4d26-b205-1442f8e031ab-image.png
                          0_1556213772599_8a754c36-c9f0-4944-9321-6a467c0b3431-image.png
                          0_1556213365670_97704c96-1c78-4e8d-a8f3-d6ed2356bc05-image.png

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

                            Hi
                            Do NOT make new instances of the main window class like you do
                            alt text

                            that is just plain wrong.

                            You are already in an instance. So no need to ever make new ones.
                            you can simply use the ch_topic variable.
                            Its already declared in the MainWindow you are using already.

                            D 1 Reply Last reply
                            1
                            • mrjjM mrjj

                              Hi
                              Do NOT make new instances of the main window class like you do
                              alt text

                              that is just plain wrong.

                              You are already in an instance. So no need to ever make new ones.
                              you can simply use the ch_topic variable.
                              Its already declared in the MainWindow you are using already.

                              D Offline
                              D Offline
                              dvlpr.bernard
                              wrote on last edited by
                              #40

                              @mrjj
                              Sir, that's what I did before but whenever I do that it says 0_1556214114582_f2ded59c-c3a3-4d57-aae1-428aaa89e276-image.png

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

                                well
                                just use the variable directly. no need to use function.
                                im not sure what get_ch_tipic is as you dont have () so its not function call.

                                However, if you do

                                QString MyX; ( in .h as you shown)

                                then anywhere you can just use it like

                                MyX = "";
                                or read it.

                                alt text
                                is just bad syntax.
                                as you say get_ch_Topic is a object with the function getTopic and its not true.

                                if you gave MainWindow a function called getTopic
                                then just call it
                                qDebug() << getTopic();

                                Its important to understand that all you add to MainWindow class ( in .h)
                                can be access from any functio that also a memebr .
                                that is
                                MainWindow::SomeFunction() {
                                any variable from .h you can use here. no special syntax. just use it.
                                }

                                1 Reply Last reply
                                3
                                • D Offline
                                  D Offline
                                  dvlpr.bernard
                                  wrote on last edited by
                                  #42

                                  Thank you sir. I just don't know but still it doesn't work it just return "" not "WHILE". :(

                                  mrjjM 1 Reply Last reply
                                  0
                                  • D dvlpr.bernard

                                    Thank you sir. I just don't know but still it doesn't work it just return "" not "WHILE". :(

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

                                    @dvlpr.bernard
                                    hi
                                    check code where you set it.
                                    Maybe you create other instance you set it on ?

                                    D 1 Reply Last reply
                                    0
                                    • mrjjM mrjj

                                      @dvlpr.bernard
                                      hi
                                      check code where you set it.
                                      Maybe you create other instance you set it on ?

                                      D Offline
                                      D Offline
                                      dvlpr.bernard
                                      wrote on last edited by
                                      #44

                                      @mrjj
                                      Hello sir,
                                      Where should I declare a global instance / object in my 3 files.
                                      mainwindow.h, main.cpp, or mainwindow.cpp?
                                      Ang how whenever I declare one because whenever I declare one e.g. (MainWindow get_ch_Topic;) it display an error "no previous extern declaration for non-static variable"

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • D dvlpr.bernard

                                        @mrjj
                                        Hello sir,
                                        Where should I declare a global instance / object in my 3 files.
                                        mainwindow.h, main.cpp, or mainwindow.cpp?
                                        Ang how whenever I declare one because whenever I declare one e.g. (MainWindow get_ch_Topic;) it display an error "no previous extern declaration for non-static variable"

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #45

                                        @dvlpr.bernard said in Advice about the application I will be making? (I'm a beginner):

                                        Where should I declare a global instance / object in my 3 files.

                                        Nowhere! Avoid global variables especially if those are derived from QObject!
                                        Why do you need global variables at all?

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        D 1 Reply Last reply
                                        2
                                        • jsulmJ jsulm

                                          @dvlpr.bernard said in Advice about the application I will be making? (I'm a beginner):

                                          Where should I declare a global instance / object in my 3 files.

                                          Nowhere! Avoid global variables especially if those are derived from QObject!
                                          Why do you need global variables at all?

                                          D Offline
                                          D Offline
                                          dvlpr.bernard
                                          wrote on last edited by
                                          #46
                                          This post is deleted!
                                          D 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