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. Serializing a widget
Forum Updated to NodeBB v4.3 + New Features

Serializing a widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
37 Posts 7 Posters 7.9k Views 3 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.
  • E Offline
    E Offline
    EL-jos
    wrote on last edited by
    #11

    I found in a forum, they say you need to recompile Qt and SQL Drive but it doesn't explain how to do it.

    Please if there is someone who knows how to make it watch you manifest

    mrjjM 1 Reply Last reply
    0
    • E EL-jos

      I found in a forum, they say you need to recompile Qt and SQL Drive but it doesn't explain how to do it.

      Please if there is someone who knows how to make it watch you manifest

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

      @EL-jos
      Hi
      For QSQLITE
      you need to compile nothing or add any libraries.
      just
      QT += sql
      in your .pro file

      1 Reply Last reply
      2
      • E Offline
        E Offline
        EL-jos
        wrote on last edited by
        #13

        Thank you very much for your advice, but I have two questions;
        first how to update a QscrollArea that already contains elements beforehand?
        and the second is how to make a message waiting list like this if a client "A" has just logged out and another client "B" sends him a message, that the message is in a list to wait for the client "A" to read it.
        like whatsapp or facebook notification when someone sends us a message while we're away, the message is kept until we read it?

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

          Hi,

          You just append new widgets to the layout that already contains the others.

          As for the messages, if you are thinking on how it’s working on mobile platform, you’ll have several things to take into consideration.

          So some questions for you:

          • On what platform(s) is your application going to run ?
          • How are the client going to talk to each other ?

          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
          1
          • E Offline
            E Offline
            EL-jos
            wrote on last edited by
            #15

            Regarding the update of my scroollArea, I don't want to add elements but rather delete completely what it already contains.

            then for the messages I want my application to run all over the platform but first on Pc using the windows operating system.

            for my clients, I use TCP/ip protocol so with QTcpSocket class

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

              The most elegant would likely be to have the messages stored in a model and then have a custom QStyledItemDelegate to paint whatever you want.

              Again: how are you client talking to each other ? Through a central server ? How do they know each other ?

              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
              • E Offline
                E Offline
                EL-jos
                wrote on last edited by
                #17

                Hi,

                Yes I use a server for the dialog between client, this means that if a client'A' sends a message to client'B', it will first go through the server then the server will send me to the destination so client'B'.

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  EL-jos
                  wrote on last edited by
                  #18

                  please someone has an idea.

                  mrjjM 1 Reply Last reply
                  0
                  • E EL-jos

                    please someone has an idea.

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

                    @EL-jos
                    About ?

                    1 Reply Last reply
                    0
                    • E Offline
                      E Offline
                      EL-jos
                      wrote on last edited by
                      #20

                      In fact I want to make sure that if we send a message to a client that is not connected, that this client sees the message that has been sent as soon as it is connected.

                      JKSHJ 1 Reply Last reply
                      0
                      • E EL-jos

                        In fact I want to make sure that if we send a message to a client that is not connected, that this client sees the message that has been sent as soon as it is connected.

                        JKSHJ Offline
                        JKSHJ Offline
                        JKSH
                        Moderators
                        wrote on last edited by JKSH
                        #21

                        @EL-jos said in Serializing a widget:

                        I want to make sure that if we send a message to a client that is not connected, that this client sees the message that has been sent as soon as it is connected.

                        Then the central server must store the message. When the client comes online, the server can deliver the message to the client.

                        Note: This concept is about communications architecture. This is not related to widgets at all.

                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                        1 Reply Last reply
                        2
                        • E Offline
                          E Offline
                          EL-jos
                          wrote on last edited by
                          #22

                          ahhhhh yes you're right, so I can store the message in a database at the server level then as soon as the concerned client is connected the server will be able to restore the message then send it to the client, thank you very much.

                          then a second unresolved problem so far;
                          here I have a scrollArea which first contains many widgets of different type, so I want to delete either empty all these widgets and left the scrollArea blank so without element,
                          how do I do that?

                          JKSHJ 1 Reply Last reply
                          0
                          • E EL-jos

                            ahhhhh yes you're right, so I can store the message in a database at the server level then as soon as the concerned client is connected the server will be able to restore the message then send it to the client, thank you very much.

                            then a second unresolved problem so far;
                            here I have a scrollArea which first contains many widgets of different type, so I want to delete either empty all these widgets and left the scrollArea blank so without element,
                            how do I do that?

                            JKSHJ Offline
                            JKSHJ Offline
                            JKSH
                            Moderators
                            wrote on last edited by
                            #23

                            @EL-jos said in Serializing a widget:

                            here I have a scrollArea which first contains many widgets of different type, so I want to delete either empty all these widgets and left the scrollArea blank so without element,
                            how do I do that?

                            Have a read through http://doc.qt.io/qt-5/qscrollarea.html . Do you see anything that might do what you want?

                            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                            1 Reply Last reply
                            0
                            • E Offline
                              E Offline
                              EL-jos
                              wrote on last edited by
                              #24

                              I just read and reread the Qt documentation for the QScrollArea class or even its mother classes but I can't find the solution to my problem because there is not a function that allows to remove all widgets contained in a scrollAreea

                              mrjjM 1 Reply Last reply
                              0
                              • E EL-jos

                                I just read and reread the Qt documentation for the QScrollArea class or even its mother classes but I can't find the solution to my problem because there is not a function that allows to remove all widgets contained in a scrollAreea

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

                                @EL-jos
                                Hi
                                Are the widgets not in a layout ?
                                You can clear layout with

                                void clearLayout(QLayout *layout)
                                    QLayoutItem *item;
                                    while((item = layout->takeAt(0))) {
                                        if (item->layout()) {
                                            clearLayout(item->layout());
                                            delete item->layout();
                                        }
                                        if (item->widget()) {
                                            delete item->widget();
                                        }
                                        delete item;
                                    }
                                }
                                
                                1 Reply Last reply
                                1
                                • E Offline
                                  E Offline
                                  EL-jos
                                  wrote on last edited by
                                  #26

                                  Thank you for your code.
                                  theoretically it works but not in practice according to my example, here is a little project I created to test your code:

                                  [7_1535474695539_fenetre1.cpp](Uploading 100%) [6_1535474695538_fenetre1.h](Uploading 100%) [5_1535474695538_fenetresecond.cpp](Uploading 100%) [4_1535474695537_fenetresecond.h](Uploading 100%) [3_1535474695537_fenetresecond.ui](Uploading 100%) [2_1535474695537_main.cpp](Uploading 100%) [1_1535474695535_Oc.pro](Uploading 100%) [0_1535474695483_Oc.pro.user](Uploading 100%)

                                  1 Reply Last reply
                                  0
                                  • E Offline
                                    E Offline
                                    EL-jos
                                    wrote on last edited by
                                    #27

                                    sorry I can't send my project on topic, send me your E-mail address so I can send it to you by E-mail

                                    mrjjM 1 Reply Last reply
                                    0
                                    • E EL-jos

                                      sorry I can't send my project on topic, send me your E-mail address so I can send it to you by E-mail

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

                                      @EL-jos
                                      Sorry i dont have email i use for Qt forum.
                                      You can use dropbox or google drive.
                                      Are you sure u give it the correct layout ?
                                      Im sure code works so maybe its other layout u clear that u think.
                                      also use the debugger to see what happens.

                                      1 Reply Last reply
                                      0
                                      • E Offline
                                        E Offline
                                        EL-jos
                                        wrote on last edited by
                                        #29

                                        Yes thank you sorry it was a small mistake on my part and there it works correctly, here is the code:

                                        void Controleur::on_pushButton_clicked()
                                        {
                                            QLayoutItem *item;
                                        
                                            int nb = 3;
                                            int a = 0;
                                            qDebug() << nb;
                                        
                                            while(ui->scrollAreaWidgetContents->layout()->count() > 0){
                                        
                                            for(int i = 0; i < ui->scrollAreaWidgetContents->layout()->count(); ++i){
                                        
                                                item = ui->scrollAreaWidgetContents->layout()->takeAt(i);
                                                if(item->layout()){
                                        
                                                    qDebug("It's a layout");
                                                    delete item->layout();
                                                }
                                        
                                                if(item->widget()){
                                        
                                                    qDebug("It's a widget");
                                                    delete item->widget();
                                                }
                                        
                                                delete item;
                                            }
                                        
                                            qDebug() << "suppression N°" << a;
                                            ++a;
                                            }
                                        }
                                        
                                        mrjjM 1 Reply Last reply
                                        0
                                        • E EL-jos

                                          Yes thank you sorry it was a small mistake on my part and there it works correctly, here is the code:

                                          void Controleur::on_pushButton_clicked()
                                          {
                                              QLayoutItem *item;
                                          
                                              int nb = 3;
                                              int a = 0;
                                              qDebug() << nb;
                                          
                                              while(ui->scrollAreaWidgetContents->layout()->count() > 0){
                                          
                                              for(int i = 0; i < ui->scrollAreaWidgetContents->layout()->count(); ++i){
                                          
                                                  item = ui->scrollAreaWidgetContents->layout()->takeAt(i);
                                                  if(item->layout()){
                                          
                                                      qDebug("It's a layout");
                                                      delete item->layout();
                                                  }
                                          
                                                  if(item->widget()){
                                          
                                                      qDebug("It's a widget");
                                                      delete item->widget();
                                                  }
                                          
                                                  delete item;
                                              }
                                          
                                              qDebug() << "suppression N°" << a;
                                              ++a;
                                              }
                                          }
                                          
                                          mrjjM Offline
                                          mrjjM Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #30

                                          @EL-jos
                                          Hi
                                          Ok super.
                                          You also want to remove any layout it has ?
                                          Normally one wish to keep layout and only remove widgets.

                                          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