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. Q table widget problem, Urgent!!!!!!
QtWS25 Last Chance

Q table widget problem, Urgent!!!!!!

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtablewidget
16 Posts 3 Posters 5.6k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    QT table widget , Hello guys i have a doubt with regards to table widget. I am devleloping the GUI. I use the designer to dot the designing and the development is done in c++, so i have a header file and .cpp file named Control window, and i have created a 3 table widget using designer, and their respective items has been declered in the header files. in the constructor .cpp file i create the rows and columns and in my function setdata i update the datas with my incoming dynamic datas which keep changing. Now the problem is by default when i click the header of the tablewidget which are by the way column names given in the designer the data gets sorted, but i have few empty blanks which are coming up during the sort. once clicked ascending happens and next time descending. while ascending the empty rows are coming up. How can i solve the problem??

    Constraints:
    The dynamic datas are of integer type.
    I cannot use tableview.
    I have to imlement the same for % more tablewidget items.

    ? kshegunovK 2 Replies Last reply
    0
    • ? A Former User

      QT table widget , Hello guys i have a doubt with regards to table widget. I am devleloping the GUI. I use the designer to dot the designing and the development is done in c++, so i have a header file and .cpp file named Control window, and i have created a 3 table widget using designer, and their respective items has been declered in the header files. in the constructor .cpp file i create the rows and columns and in my function setdata i update the datas with my incoming dynamic datas which keep changing. Now the problem is by default when i click the header of the tablewidget which are by the way column names given in the designer the data gets sorted, but i have few empty blanks which are coming up during the sort. once clicked ascending happens and next time descending. while ascending the empty rows are coming up. How can i solve the problem??

      Constraints:
      The dynamic datas are of integer type.
      I cannot use tableview.
      I have to imlement the same for % more tablewidget items.

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      @VInay123 Hi, and welcome to the Qt forum!

      How can i solve the problem?

      That's some bug in your code and you need to fix it. Sorry but how should anyone here be able to help you with this?

      ? 1 Reply Last reply
      0
      • ? A Former User

        @VInay123 Hi, and welcome to the Qt forum!

        How can i solve the problem?

        That's some bug in your code and you need to fix it. Sorry but how should anyone here be able to help you with this?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @Wieland Hi thank you for the reply. Actually i am using default sorting criteria enabled. I.e Set sortEnabled(true);

        I have a table of 20 rows constructed in the constructor. And i get some data which can be less than 20 but not more than that. I put that datas in the rows. as the data is being updated dynamically, sometime only two rows are filled and sometimes 10 and meanwhile when i click the header or column name it gets sorted. whilewhile ascending say i have only 10 rows filled and rest 10 are empty, when i click the column the empty 10 are coming first and later the filled onces according to ascending oreder.

        ? 1 Reply Last reply
        0
        • ? A Former User

          @Wieland Hi thank you for the reply. Actually i am using default sorting criteria enabled. I.e Set sortEnabled(true);

          I have a table of 20 rows constructed in the constructor. And i get some data which can be less than 20 but not more than that. I put that datas in the rows. as the data is being updated dynamically, sometime only two rows are filled and sometimes 10 and meanwhile when i click the header or column name it gets sorted. whilewhile ascending say i have only 10 rows filled and rest 10 are empty, when i click the column the empty 10 are coming first and later the filled onces according to ascending oreder.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @VInay123 Okay, understood. Try to disable sorting before you insert new elements and after that reenable it again. (void QTableView::setSortingEnabled(bool enable)).

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

            So i should disable the sorting in my constructor, and in my function where i put the elements in the table after the loop i should enable it?

            1 Reply Last reply
            0
            • ? A Former User

              @VInay123 Okay, understood. Try to disable sorting before you insert new elements and after that reenable it again. (void QTableView::setSortingEnabled(bool enable)).

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              @Wieland I tried doing it, but still i have the same problem. :(

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

                Maybe the workaround mentioned in QTBUG-7483 can help.

                1 Reply Last reply
                0
                • ? A Former User

                  QT table widget , Hello guys i have a doubt with regards to table widget. I am devleloping the GUI. I use the designer to dot the designing and the development is done in c++, so i have a header file and .cpp file named Control window, and i have created a 3 table widget using designer, and their respective items has been declered in the header files. in the constructor .cpp file i create the rows and columns and in my function setdata i update the datas with my incoming dynamic datas which keep changing. Now the problem is by default when i click the header of the tablewidget which are by the way column names given in the designer the data gets sorted, but i have few empty blanks which are coming up during the sort. once clicked ascending happens and next time descending. while ascending the empty rows are coming up. How can i solve the problem??

                  Constraints:
                  The dynamic datas are of integer type.
                  I cannot use tableview.
                  I have to imlement the same for % more tablewidget items.

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

                  @VInay123 said:

                  i have created a 3 table widget using designer, and their respective items has been declered in the header files.

                  What items are declared in the header, how and why? Please show how you populate the widget(s) and other relevant pieces of the code.

                  I cannot use tableview.

                  You are already using a table view. QTableWidget derives from QTableView.

                  Also what version of Qt are you using?

                  Read and abide by the Qt Code of Conduct

                  ? 1 Reply Last reply
                  1
                  • kshegunovK kshegunov

                    @VInay123 said:

                    i have created a 3 table widget using designer, and their respective items has been declered in the header files.

                    What items are declared in the header, how and why? Please show how you populate the widget(s) and other relevant pieces of the code.

                    I cannot use tableview.

                    You are already using a table view. QTableWidget derives from QTableView.

                    Also what version of Qt are you using?

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    @kshegunov
                    From the designer i get a header file where the Qtablewidget is declared.

                    I have a separate cpp and header file for development process, this header file has the inclusion of the header file obtained from designer.

                    In the development header file i declare a pointer of Qtablewidget items[][];

                    and in cpp the constructor i populate the items so a table is created .

                    and in my funtion i fill the table

                    I use qt 4.7.8

                    ? 1 Reply Last reply
                    0
                    • ? A Former User

                      @kshegunov
                      From the designer i get a header file where the Qtablewidget is declared.

                      I have a separate cpp and header file for development process, this header file has the inclusion of the header file obtained from designer.

                      In the development header file i declare a pointer of Qtablewidget items[][];

                      and in cpp the constructor i populate the items so a table is created .

                      and in my funtion i fill the table

                      I use qt 4.7.8

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      @VInay123 said:

                      I use qt 4.7.8

                      Ok, then it's clearly the bug I refered to before, QTBUG-7483.

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

                        @Wieland when we click the column names of the table widget i get a small arrow inside and sorting happens one click ascending and one click descending. How do i disable it?? i tried setsortingenabled(false) but its still sorting

                        ? 2 Replies Last reply
                        0
                        • ? A Former User

                          @Wieland when we click the column names of the table widget i get a small arrow inside and sorting happens one click ascending and one click descending. How do i disable it?? i tried setsortingenabled(false) but its still sorting

                          ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #12

                          @VInay123 I can only test it with Qt 5.6. With this, in the designer there is a property sortingEnabled. When this isn't selected I don't get the small arrow and clicking the header does not cause any sorting.

                          1 Reply Last reply
                          2
                          • ? A Former User

                            @Wieland when we click the column names of the table widget i get a small arrow inside and sorting happens one click ascending and one click descending. How do i disable it?? i tried setsortingenabled(false) but its still sorting

                            ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #13

                            @VInay123 Also with Qt 5.6 ascending and descending sorting works as expected. Can't you update to a more recent Qt version?

                            ? 2 Replies Last reply
                            0
                            • ? A Former User

                              @VInay123 Also with Qt 5.6 ascending and descending sorting works as expected. Can't you update to a more recent Qt version?

                              ? Offline
                              ? Offline
                              A Former User
                              wrote on last edited by
                              #14

                              @Wieland I havent check that box of sort enabled in the property box, but it is in bold compared to other properties. And because i work with a other software called ADTF , higher versions are not compatible :(

                              1 Reply Last reply
                              0
                              • ? A Former User

                                @VInay123 Also with Qt 5.6 ascending and descending sorting works as expected. Can't you update to a more recent Qt version?

                                ? Offline
                                ? Offline
                                A Former User
                                wrote on last edited by
                                #15

                                @Wieland
                                I have a question, i think i could use the signal when i click header.

                                Actually with designer i have created rows and column names. now i would like to use the signal when i click the column.
                                right now i use QObject::connect(ui.tablewidget->verticalheader(), SIGNAL(sectionPressed(int)), this, SLOT(function(int))).
                                But i am never receiving a signal. I tried using sectionClicked(int) or sectionDoubleClicked(int). which is an approporiate one to know whther a user has clicked the header or column name ones or twice?

                                ? 1 Reply Last reply
                                0
                                • ? A Former User

                                  @Wieland
                                  I have a question, i think i could use the signal when i click header.

                                  Actually with designer i have created rows and column names. now i would like to use the signal when i click the column.
                                  right now i use QObject::connect(ui.tablewidget->verticalheader(), SIGNAL(sectionPressed(int)), this, SLOT(function(int))).
                                  But i am never receiving a signal. I tried using sectionClicked(int) or sectionDoubleClicked(int). which is an approporiate one to know whther a user has clicked the header or column name ones or twice?

                                  ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on last edited by
                                  #16

                                  @VInay123 Hi! This works for me (Qt 5.6):

                                  connect( ui->tableWidget->verticalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(sayHi()) );
                                  
                                  1 Reply Last reply
                                  1

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved