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. Small QLineEdit
Forum Updated to NodeBB v4.3 + New Features

Small QLineEdit

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 664 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
    DrZod
    wrote on last edited by
    #1

    I am trying to make a Sudoku.I want to take the inputs using QLineEdit but i cant make the size to be small it is always too wide.How can I make the QLineEdits be as small as 1 digit??

    JonBJ 1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You can use setFixedWidth(), but be careful about the font.Different systems can have different font styles and sizes, so if you want to go with a fixed size widget make sure the font is fixed too. Otherwise you can use QFontMetrics to get the width of a digit with your current font.

      1 Reply Last reply
      1
      • D Offline
        D Offline
        DrZod
        wrote on last edited by
        #3

        Thanks it worked!.Exactly what i wanted.

        1 Reply Last reply
        0
        • D DrZod

          I am trying to make a Sudoku.I want to take the inputs using QLineEdit but i cant make the size to be small it is always too wide.How can I make the QLineEdits be as small as 1 digit??

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @DrZod

          I am trying to make a Sudoku.I want to take the inputs using QLineEdit

          That would mean creating 81 QLineEdits for a standard-sized Sudoku board. I'm not sure in Qt, but this may be regarded as bad practice? My thought (in your next iteration, for public release :) ) would be something like a QTableWidget containing at worst a QLabel or better just plain text without a widget most of the time, with a change over to editable (QLineEdit or otherwise) at the instant user clicks into cell, revert back once clicked outside?

          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