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. Slow form
Qt 6.11 is out! See what's new in the release blog

Slow form

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 1.8k 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,

    another beginner's question that sounds more like a I'm looking for a needle in a bottle:
    I have several forms, all of them are opened instantly when I click the QAction from the QToolBar from mainwindow, except one. this form is very slow; it takes two one seconds or more. any idea where to start to look for the delay? or is there a possibility to measure the exec() time?

    cheers

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      What r u loading in the form ? U can put some debug messages in slot and try to put message box inside slot to check whether it is quick ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

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

        In the form is loaded several widgets:
        pushButtons, lineEdits, labels (that takes some values from a database), one tableView (that takes some values from a database, displayed via a QSqlQueryModel, QSortFilterProxyModel), several Sql queries (the biggest is one with INSERT 40 elements when a pushButton is triggered), widgets that are originally hidden and when a RadioButton is pushed they are showed, etc.

        I put a qDebug() message in the mainWindow when the QAction is triggered, the message is shown on the Application Output instant, so the delay has to do with the opening form.

        any idea? thank you

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ckakman
          wrote on last edited by
          #4

          SQL queries may be the reason. Don't start the queries immediately but use a slot which you can call with, for example,
          @QTimer::singleShot(0, this, SLOT(...))@

          If you have some experience with threads, QThreadPool or QtConcurrent, you can run the queries in a worker thread and then populate the Uİ.

          1 Reply Last reply
          0
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
            wrote on last edited by
            #5

            Your answer itself proves that it is not a issue with QAction and coming to your slot. You are doing some time consuming tasks in your slots. As suggested by previous post, SQL operations could be real target of slowness. Just see whether you can move these operations to some thread and handle it.

            Dheerendra
            @Community Service
            Certified Qt Specialist
            https://www.pthinks.com

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

              hi all,

              thanks for your feedback. I've been reading about QThread. this should be a powerful tool, especially when it comes to priority. I'm trying to create a separate class run the thread, but I'm not sure how to connect it to my widget (lineEdit) that should show the returned query value.

              any hints?
              thanks

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

                Hi,

                The worker object approach described in Qt 5 QThread's documentation. Give it a signal that you'll connect to your QLineEdit and you should be good to go.

                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

                • Login

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