Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED]Please review this small code
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Please review this small code

Scheduled Pinned Locked Moved Qt Creator and other tools
10 Posts 5 Posters 2.7k 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.
  • R Offline
    R Offline
    rajatgupta431
    wrote on last edited by
    #1

    HERE is the code for a slider that changes the value of the progress bar. The problem is, at a time only one progress bar works . Though both of them are connected, niether of them disconnected.

    @#include “mainwindow.h”

    #include “ui_mainwindow.h”

    MainWindow::MainWindow(QWidget *parent) :

    QMainWindow(parent), ui(new Ui::MainWindow)
    {

    ui->setupUi(this);

    connect(ui->horizontalSlider,SIGNAL),ui->progressBar,SLOT));

    ui->setupUi(this);
    connect(ui->horizontalSlider,SIGNAL),ui->progressBar_2,SLOT));

    }

    MainWindow::~MainWindow()
    { delete ui;
    }@

    1 Reply Last reply
    0
    • _ Offline
      _ Offline
      _rmn
      wrote on last edited by
      #2

      your code is damaged.. put it between '@' symbols
      Anyway you dont need to call
      @
      ui->setupUi(this)@

      twice. Remove the second one

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rajatgupta431
        wrote on last edited by
        #3

        thanks a lot _rmn.
        I am a beginner, started with Qt yesterday itself. Can You pls explain me the reason , how does calling twice affect it??

        1 Reply Last reply
        0
        • L Offline
          L Offline
          luca
          wrote on last edited by
          #4

          I think "Qt DOC":http://qt-project.org/doc/qt-4.8/ could be a good start for you.

          Edit:
          You should avoid upper case in the title of the post.

          1 Reply Last reply
          0
          • _ Offline
            _ Offline
            _rmn
            wrote on last edited by
            #5

            If you look inside setupUI method, then you can see that in its generated code all widgets from your .ui file is newly created. So all you do with it inside your code before calling setupUi method second time is lost. Also call setupUi method twice and more is not memory safe.
            Read more at: http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Sam
              wrote on last edited by
              #6

              Hi,

              The form created using QtDesigner is stored as an xml file, setupUi() is a function that creates the actual instances of the widgets that you created using the QtDesigner.

              The title of your post should be more specific/related to the problems/errors you are getting.

              Kindly read "Forum Help":http://qt-project.org/wiki/ForumHelp guidelines for more information.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rajatgupta431
                wrote on last edited by
                #7

                Thanks a lot for the helpful information.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  leon.anavi
                  wrote on last edited by
                  #8

                  [quote author="rajatgupta431" date="1355396444"]
                  I am a beginner, started with Qt yesterday itself. [/quote]

                  Welcome to the forum and have fun with Qt :) Please when you post your source mark is as code by clicking the code button or by just surrounding it with @

                  http://anavi.org/

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    rajatgupta431
                    wrote on last edited by
                    #9

                    [quote author="leon.anavi" date="1355398574"]

                    Welcome to the forum and have fun with Qt :) Please when you post your source mark is as code by clicking the code button or by just surrounding it with @

                    [/quote]

                    Sure,I ll do as said :)

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      rajatgupta431
                      wrote on last edited by
                      #10

                      [quote author="Luca" date="1355397400"]

                      Edit:
                      You should avoid upper case in the title of the post.[/quote]
                      Done :)

                      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