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. [SOLVED] Selecting a label
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Selecting a label

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.9k 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.
  • A Offline
    A Offline
    ArchGabe
    wrote on last edited by
    #1

    Hi guys,
    .
    I am new to Qt and I am trying to develop an user interface with it.
    .
    I have two questions:
    .
    1- Is it possible to add widgets without using vertical/ horizontal layouts? I want to add some labels in runtime inside a scroll area for exemple, but the parent widget (the scroll area) has no children so I could use any layout.
    .
    2- Is it possible to select a label? I mean, I have several labels, each one showing a QPicture/ QPixmap and I want to select one of them to display its picture in high resolution. Is it possible?
    .
    Thank you all in advance,

    Gabe

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      You can position widgets manually but really sounds like you want a QGraphicsView and QGraphicsScene.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ArchGabe
        wrote on last edited by
        #3

        Hello! Thank you very much for you reply!
        .
        Actually I already solved my problem, but now I am with a new and more difficult one:
        .
        I created a list of a random number o buttons, where each button is created by the user by pressing a main button, called "New button". Now, I need to add some funcionality to these new created buttons.
        .

        I created a class AddButton as:
        @
        class AddButton{

        publilc:
        AddButton() {}
        AddButton(QString, QIcon);
        QPushButton returnButton(void) {return *newButton;};
        QIcon returnIcon(void) {return *img;}

        protected:
        QString name;
        QIcon img;
        QPushButton
        newButton;
        };
        @
        .
        Then, I created a list, using std::list to store every new button the user creates. Like std::list<AddButton> btnList;
        .
        Now, I need that these buttons do something. Every button will have the same functionality, displaying its name on a text field, for exemple.
        .
        Does anyone here have any idea of how can I do that?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rondog
          wrote on last edited by
          #4

          For your first post I don't see why you don't want to use the layouts. They are dynamic and much easier than the alternative.

          For the buttons you need to connect the button signals you are interested to the main class

          @
          class Parent_Widget : QWidget
          {
          Q_OBJECT
          ...
          public slots:
          void Button_Clicked(void);
          };

          QPushButton* AddButtonClass::returnButton(Parent_Widget *parent)
          {
          QPushButton *new_button = new QPushButton(parent);

          connect(new_button,SIGNAL(clicked(void)),parent,SLOT(Button_Clicked(void)));

          return new_button;
          }

          @

          I don't think you need a class for the purpose of creating buttons; I would think it should be part of the parent class.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ArchGabe
            wrote on last edited by
            #5

            Hello! Thank you for your reply! Now this part of the code is working great! Thank you!

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ArchGabe
              wrote on last edited by
              #6

              Wrong place! Sorry!

              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