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] Label overflow?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Label overflow?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.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.
  • D Offline
    D Offline
    david.luggen
    wrote on last edited by
    #1

    Hello

    Currently there happend something strange while I created a new class. There I added to the Header 3 QLabel's and a QGridLayout like this:

    @private:

    QLabel *first;
    QLabel *second;
    QLabel *third;
    
    QGridLayout *gridLayout;@
    

    Then I instance and added them in the source file to the layout, like:

    @
    first = new QLabel("first");
    second = new QLabel("second");
    third = new QLabel("third");

    gridLayout = new QGridLayout;
    gridLayout->addWidget(first, 0, 0);
    gridLayout->addWidget(second, 1, 0);
    gridLayout->addWidget(third, 2, 0);
    
    setLayout(gridLayout);@
    

    Then I creat from this class a Widget in the QMainWindow. Now, as I set this Widget show(), I get a runtime error. Curiously to say, if I add just two Labels, it works, from three Labels on I get this error. The other part is, if I define the QLabel's direclty in the source file like @QLabel *first = New QLabel("first")@ it works as well, what could cause this?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tdmatsu
      wrote on last edited by
      #2

      I don't see any problems in your code. Could you elaborate this part a little bit?

      [quote author="luggi" date="1306942242"]
      Then I creat from this class a Widget in the QMainWindow. Now, as I set this Widget show(), I get a runtime error.
      [/quote]

      How are you using the widget in QMainWindow? What is the error message?

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

        Just a guess: perhaps you should set the size of the grid to be big enough so you actually have 3 columns?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          david.luggen
          wrote on last edited by
          #4

          The widget is used in the QMainWindow like this.

          In the header:

          @private:
          MyWidget *myWidget;@

          In the source file:

          @ myWidget = new myWidget;
          connect(aPushButton, SIGNAL(clicked()), myWidget, SLOT(show()));@

          Everytime I click on this Button, the application freezes totally and Windows 7 is searching for a solution of this problem. The Qt Creator gives me the exit code -1073741819. I was searching a bit around this code and found something about access violation in windows.

          @Andre: How can I set the size of the grid? I just found to set the height or width of a row or column.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chuck Gao
            wrote on last edited by
            #5

            Maybe error occurs in another place :)
            The grid will resize automatically by itself. So you don't need to worry about it.

            Chuck

            1 Reply Last reply
            0
            • D Offline
              D Offline
              david.luggen
              wrote on last edited by
              #6

              Okey, there are some news. If I set this class in the QMainWindow public like
              @public:
              MainWindow(QWidget *parent = 0);
              ~MainWindow();

              MyWidget *myWidget;@
              

              then it works. But I don't get why I get problems if the class is private?

              1 Reply Last reply
              0
              • D Offline
                D Offline
                david.luggen
                wrote on last edited by
                #7

                Now it's time to close this thread, as I set the class back to private, just to try it a second time which I think is still necessary in windows, it worked! :-/

                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