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

Conditional error

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 456 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.
  • K Offline
    K Offline
    Kycho
    wrote on last edited by
    #1

    I have experienced strange phenomenon from one day.

    This was a simple source that worked well in the past.
    But now it does not work.

       QPushButton *test[2];
       test[0] = new QPushButton;
       qDebug() << "!test[0] =" <<!test[0];
       qDebug() << "!test[1] =" <<!test[1];
    
    
    result :
    !test[0] = false
    !test[1] = false
    

    I want " !test[1] = true " result...
    Is it my fault?
    So what should I do?

    Thanks in advance for your advice.

    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 dheerendra
      #2

      @Kycho said in Conditional error:

      QPushButton *test[2];

      This declaration is array of pointers. These two pointers are not initialised with anything. So you don't know what will get initialised. It will have some random value. !<randomvalue> will be always false.

      So result is as per your code.

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

      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