实现一个按钮的隐藏与显示。

DuanHuixin12 2015-03-21 11:47:25
大神们。为什么单击Button按钮后,只会隐藏却无法在现实?





void ccc::on_pushButton_7_clicked()

{
static int flg = 1;

switch(flg) //switch选择fla语句
{
case 0:
ui->pushButton_7->hide(); //窗帘放下
flg = 1; //fla初始化为1
break; //结束
case 1:
ui->pushButton_7->show(); //窗帘卷起
flg = 0; //fla初始化为0
break; //结束
}
}
...全文
627 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaodong60606 2015-03-23
  • 打赏
  • 举报
回复
setVistble 显示隐藏,setEnable 变灰不能点击
DuanHuixin12 2015-03-22
  • 打赏
  • 举报
回复
引用 8 楼 DuanHuixin12 的回复:
[quote=引用 6 楼 nigoole 的回复:]
void ccc::on_pushButton_7_clicked()

   {
       static int flg = 1;

        switch(flg)       //switch选择fla语句
        {
            case 0:
                ui->pushButton_7->setVisible(flase); //窗帘放下
                flg = 1;      //fla初始化为1
                break;       //结束
            case 1:
              ui->pushButton_7->setVisible(true); //窗帘卷起
                flg = 0;      //fla初始化为0
            break;        //结束
      }
    }
可是用flase会出现代码错误。[/quote]“” flase was not declared in this scope
DuanHuixin12 2015-03-22
  • 打赏
  • 举报
回复
引用 6 楼 nigoole 的回复:
void ccc::on_pushButton_7_clicked()

   {
       static int flg = 1;

        switch(flg)       //switch选择fla语句
        {
            case 0:
                ui->pushButton_7->setVisible(flase); //窗帘放下
                flg = 1;      //fla初始化为1
                break;       //结束
            case 1:
              ui->pushButton_7->setVisible(true); //窗帘卷起
                flg = 0;      //fla初始化为0
            break;        //结束
      }
    }
可是用flase会出现代码错误。“” flase was not declared in this scope
DuanHuixin12 2015-03-22
  • 打赏
  • 举报
回复
引用 6 楼 nigoole 的回复:
void ccc::on_pushButton_7_clicked()

   {
       static int flg = 1;

        switch(flg)       //switch选择fla语句
        {
            case 0:
                ui->pushButton_7->setVisible(flase); //窗帘放下
                flg = 1;      //fla初始化为1
                break;       //结束
            case 1:
              ui->pushButton_7->setVisible(true); //窗帘卷起
                flg = 0;      //fla初始化为0
            break;        //结束
      }
    }
可是用flase会出现代码错误。
lynnhua_ 2015-03-22
  • 打赏
  • 举报
回复

// 这样更简单
void ccc::on_pushButton_7_clicked() {
    static bool bShow = true;
     bShow  = !bShow ;
    ui->pushButton_7->setVisible(bShow  );
}
lynnhua_ 2015-03-22
  • 打赏
  • 举报
回复
void ccc::on_pushButton_7_clicked()

   {
       static int flg = 1;

        switch(flg)       //switch选择fla语句
        {
            case 0:
                ui->pushButton_7->setVisible(flase); //窗帘放下
                flg = 1;      //fla初始化为1
                break;       //结束
            case 1:
              ui->pushButton_7->setVisible(true); //窗帘卷起
                flg = 0;      //fla初始化为0
            break;        //结束
      }
    }
lynnhua_ 2015-03-22
  • 打赏
  • 举报
回复
引用 10 楼 DuanHuixin12 的回复:
[quote=引用 8 楼 DuanHuixin12 的回复:] [quote=引用 6 楼 nigoole 的回复:]
void ccc::on_pushButton_7_clicked()

   {
       static int flg = 1;

        switch(flg)       //switch选择fla语句
        {
            case 0:
                ui->pushButton_7->setVisible(flase); //窗帘放下
                flg = 1;      //fla初始化为1
                break;       //结束
            case 1:
              ui->pushButton_7->setVisible(true); //窗帘卷起
                flg = 0;      //fla初始化为0
            break;        //结束
      }
    }
可是用flase会出现代码错误。[/quote]“” flase was not declared in this scope[/quote] 不好意思,写的时候出现了手误,将false写错了
dbzhang800 2015-03-21
  • 打赏
  • 举报
回复
关键代码不全,猜测一下,你的逻辑是:你是认为你能点击一个隐藏的button么?
引用 楼主 DuanHuixin12 的回复:
大神们。为什么单击Button按钮后,只会隐藏却无法在现实? void ccc::on_pushButton_7_clicked() { static int flg = 1; switch(flg) //switch选择fla语句 { case 0: ui->pushButton_7->hide(); //窗帘放下 flg = 1; //fla初始化为1 break; //结束 case 1: ui->pushButton_7->show(); //窗帘卷起 flg = 0; //fla初始化为0 break; //结束 } }
myelapse 2015-03-21
  • 打赏
  • 举报
回复
ui->pushButton->setVisible(true); 显示 ui->pushButton->setVisible(false; 隐藏
DuanHuixin12 2015-03-21
  • 打赏
  • 举报
回复
引用 1 楼 nigoole 的回复:
setVisible()
可以详细一点吗?我是初学者
DuanHuixin12 2015-03-21
  • 打赏
  • 举报
回复
可以详细一点吗?我是初学者
lynnhua_ 2015-03-21
  • 打赏
  • 举报
回复
setVisible()

16,212

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧